Say I have a table like this in Excel (except the third and last column, which is what I want to obtain)
Name
Value
What I want
X
1
1
X-Y
1
2
X-Y-Z
0
2
X-V
1
2
So in column 3 I want to do a sumif which sums the column "Value" across all rows where Name is a subset of the given name in the row being looked at.
E.g. for row 2 the returned value will be 2 - because both X and X-Y is a subset of X-Y - so it sums these two rows' values.
How can I do this in a formula?
Found the solution myself.
In C2 put
=SUMPRODUCT($B$2:$B$5; --(IFERROR(IF(FIND($A$2:$A$5;A2)>0;1;0);0)=1))
Related
I have an Excel Spreadsheet containing elements in 3 columns
Name Number Time
A 1 0.425
A 2 0.123
B 1 1.0256
B 2 0.564
B 3 0.7895
C 2 0.256
C 5 0.458
I want to choose minimum Time and corresponding Name and Number. I have tried it with pivot table and retrieved Name and minimum Time but could not get the corresponding Number column value.
EDIT :
Just to explain further. For each corresponding Name i want to choose minimum Time and then corresponding Number against that minimum Time. E.g. Output for above table should be like this :
Name Number Time
A 2 0.123
B 2 0.564
C 2 0.458
You need three formulas
Extract list of unique Name
This formula is an array formula so needs to be confirmed by holding down ctrl + shift while holding down enter
E2: =IFERROR(INDEX($A$2:$A$8,MATCH(0,COUNTIF($E$1:E1,$A$2:$A$8),0)),"")
minimum time for the Name
G2: =AGGREGATE(15,6,1/(E2=$A$2:$A$8)*$C$2:$C$8,1)
matching number for minimum time for name
F2: =AGGREGATE(14,4,(E2=$A$2:$A$8)*(G2=$C$2:$C$8)*$B$2:$B$8,1)
The screenshot below should clarify where the formulas go and the referred ranges:
Assuming your data is in A2:C8, you can use the formula:
For Name:
=INDEX(A2:C8, MATCH(MIN(C2:C8), C2:C8, 0), 1)
For Number:
=INDEX(A2:C8, MATCH(MIN(C2:C8), C2:C8, 0), 2)
A PivotTable can indeed do that for you:
This is accomplished by setting a Top 1 Values filter as follows:
I have
Year 1 2 3 4 5 6
I'm trying to make it so that each year number 1-6 is equal to another number value i.e. Year 1 is equal to 5. Year 2 is equal to 6.
You will not be able to store one value in a cell and use a different value for calculation. However you may do this calculation with the help of a lookup from another table,
Assuming you have the years in Column A and the corresponding mappings are in Column E and F, you can use the below formula in Column B,
=INDEX(E:F,MATCH(A1,E:E,0),2) * 2
This formula lookups the value in A1 in the table E:F and returns the corresponding Column F element. That is finally multiplied with the 2 to show your result. Instead of just using just A1 for multiplying by 2, you should be using INDEX(E:F,MATCH(A1,E:E,0),2). Hope this helps.
So say I have a sheet like the following:
Row 1 2 3 4 5 6
1 x
2 x
3 x x
4 x
5 x x
6 x
And I have another sheet which I want to encapsulate the data with:
1st appeared
1
2
1
4
2
6
I'm basically trying to construct the second sheet. Is there a way for each row to start at column two and go up to the ith column and display where the first 'x' appears. (Note that we can assume that every row will have at least 1 'x' when the row and column meet forming a diagonal down the entire first sheet) [Note that my first spreadsheet is roughly 5,000 x 5,000 hence why I'd like a nice formula for this instead of doing things by hand =)]
Thanks in advance!
The MATCH function return the relative position in either a row or column. Use this formula in your second worksheet.
=iferror(match("x", sheet1!1:1, 0) - 1, 0)
Fill down to retrieve the correct column index or zero if not found. A 1 is subtracted since hte want the position relative to column B. The IFERROR function return a default 0 is no match is found. Substitute "" in place of the zero if you want nothing displayed.
I have 2 sheets. Sheet 1 is set up similarly to:
Keyword Domain Rank
A Z 1
B Z 2
C Z 3
D Y 10
E Y 15
B Y 20
And sheet 2 is set up like:
Keyword (Domain Z) (Domain Y)
A 1 -
B 2 20
C 3 -
D - 10
I'm trying to have a formula that will compare the keywords in Sheet 2 with those in Sheet 1 and then return the rank that corresponds to the correct domain (that's specified in Sheet 2 for that column). I can't get any formula I use to evaluate. I've used 2 formulas so far:
=INDEX(Raw!$H$11:$H$322, MATCH(A3,IF(Raw!$D$11:$D$322=All!$B$2,Raw!$B$11:$B$322),0))
The above formula works, to a point. The problem is that it simple pulls the domain for the first instance of the keyword found, which doesn't always match the domain in the column of sheet 2. The second formula I've tried:
=INDEX(Raw!$H$11:$H$322, MATCH(B3,MATCH($C$2,Raw!$D$11:$D$322,0)))
To make the values appear in the Sheet 2 table, use the following formula:
=SUMPRODUCT(--($A$2:$A$7=E2),--($B$2:$B$7=$F$1),$C$2:$C$7)
This returns 0 for non-matches - you can either format the cells to display 0 how you want, or you can use the longer/uglier:
=IF(SUMPRODUCT(--($A$2:$A$7=E2),--($B$2:$B$7=$G$1),$C$2:$C$7)<>0,SUMPRODUCT(--($A$2:$A$7=E2),--($B$2:$B$7=$G$1),$C$2:$C$7),"-")
To calculate the rank on the first sheet based on the data from the second sheet:
=VLOOKUP(A2,$F$2:$H$5,MATCH(B2,$G$1:$H$1,0)+1,FALSE)
For sample purposes, this just put your sheet2 data in F1:H5.
This looks for the corresponding keyword and then uses match to pick the right column. I named the columns Z and Y, but if you need Domain included that can be done as well. Note that this causes an error since there is no E defined in your second table - is that the case? If so, it can be adjusted to account for no matches as follows (assuming Excel 2007):
=IFERROR(VLOOKUP(A6,$F$2:$H$5,MATCH(B6,$G$1:$H$1,0)+1,FALSE),"Rank Not Found")
You could also use PivotTable with Keywords in rows and Domain names in columns. It seems like that would do the job and be a more robust solution.
I have searched through many similar topics but could find nothing that will do what I need.
I am trying to create a worksheet that will track scores for a darts game.
On Sheet 1 I have two columns that simply tracks each players throws from 501 down to 0
Row 25 is the amount remaining for each player.
In Sheet 2 I have 2 columns. The Column A contains scores that you can check out on, and Column B contains the checkout e.g. (T20, T20, D18). So if the value in row 25 of Sheet 1 matches any of the values in Column A of sheet 2, the I want to display the Value of Column B in the matching row on Sheet 2 Underneath the remaining score on Sheet 1.
Can anyone point me in the right direction?
not sure what you mean exactly, but this formula in row 26 should do the trick:
=index('Sheet 2'!$B:$B;match(A25;'Sheet 2'!$A:$A;0))
if your list separator is comma ,, use that instead of semicolon ;
you might want to use 1 as the third argument of match function, if you want to display the checkout according to the nearest match that is bigger than the number in row 25 and the column A in Sheet 2 is sorted in ascending order (1-9)
or -1 if you want the nearest match that is smaller and column A is sorted in descending order (9-1)
You can use this:
=IFERROR(VLOOKUP(A4, Sheet2!$C$2:$E$65535, 3, FALSE),0)