Comparing Multiple Cells and Returning Values - excel

I have a spreadsheet that looks like this:
A B C D
1 Bob 10/02/2013 10
2 Bob 10/02/2013 2
3 Bob 10/02/2013 8
4 Steve 10/01/2013 6
5 Steve 10/01/2013 6
6 Sally 10/01/2013 6
The requirement is that if A1 matches anything else in column A (A1,A2, and A3) AND B1 matches anything in column B (B1,B2,B3) Then add up the values C, divide by 4 and put that in D.
I want to do this for the whole sheet (500ish rows).

You may use the SUMIFS function. Below is sample.
Formula =SUMIFS(C1:C5,A1:A5,A1,B1:B5,B1)
OR
Or can use SUMPRODUCT function .
=SUMPRODUCT($C$1:$C$5,--($A$1:$A$5=$A1)*--($B$1:$B$5=B1))/4

Related

How to SELECT N values ABOVE and BELOW from specific value

If I have a table:
Column A
Column B
Column C
1
Jane
10
2
Stewe
9
3
John
8
4
Mike
7
5
Luke
6
6
Andrew
5
7
Carl
4
8
Sasha
3
9
Ariel
2
10
Carol
1
I would like to SELECT 3 rows above and below WHERE Column B = someValue .
IF query SELECT * WHERE Column B = "Andrew" result should look like:
Column A
Column B
Column C
3
John
8
4
Mike
7
5
Luke
6
6
Andrew
5
7
Carl
4
8
Sasha
3
9
Ariel
2
I know how to select one row, but cant understand how to select such range.
Thanks for ideas!
You can limit and offset inside your QUERY():
=QUERY(A1:C,"limit "&2+MIN(5,MATCH(D1,B:B,0))&" offset "&MAX(0,MATCH(D1,B:B,0)-5))
Well, this was fun...
If 3 above or below are not available then blank... rolling data around is a different proposition.
Below the image is the list of formulae used.
So, per cell not including the data validation that is based on cells B2:B11
A14 and dragged down:
=IFERROR(INDEX($A$2:$A$11,MATCH(B14,$B$2:$B$11,0)),"")
C14 and dragged down:
=IFERROR(INDEX($C$2:$C$11,MATCH(B14,$B$2:$B$11,0)),"")
Cells B14 through B20:
=IFERROR(IF(MATCH(B$17,$B$2:$B$11,0)=3,NA(),INDEX($B$2:$B$11,MATCH(B$17,$B$2:$B$11,0)-3)),"")
=IFERROR(IF(MATCH(B$17,$B$2:$B$11,0)=2,NA(),INDEX($B$2:$B$11,MATCH(B$17,$B$2:$B$11,0)-2)),"")
=IFERROR(IF(MATCH(B$17,$B$2:$B$11,0)=1,NA(),INDEX($B$2:$B$11,MATCH(B$17,$B$2:$B$11,0)-1)),"")
=E2
=IFERROR(INDEX($B$2:$B$11,MATCH(B$17,$B$2:$B$11,0)+1),"")
=IFERROR(INDEX($B$2:$B$11,MATCH(B$17,$B$2:$B$11,0)+2),"")
=IFERROR(INDEX($B$2:$B$11,MATCH(B$17,$B$2:$B$11,0)+3),"")
In Excel 365, you could try:
=INDEX(A:C,MAX(2,MATCH(D2,B:B,0)-3),0):INDEX(A:C,MIN(COUNTA(B:B),MATCH(D2,B:B,0)+3),0)
In Google sheets, on the other hand, the formula would be:
=INDEX(A:C,MAX(2,MATCH(D2,B:B,0)-3),0):INDEX(A:C,MIN(COUNTA(B:B),MATCH(D2,B:B,0)+3),0)
(spot the difference).
Excel
Google Sheets
This should produce what you want in all cases:
=IFERROR(FILTER(A2:C,B2:B<>"",ROW(A2:A)>=VLOOKUP("Andrew",{B2:B,ROW(B2:B)},2,FALSE)-3,ROW(A2:A)<=VLOOKUP("Andrew",{B2:B,ROW(B2:B)},2,FALSE)+3))
Of course, you can replace the two instances of "Andrew" with a cell reference (one where you type a changeable name).
This just looks up the row in a curly-bracket array formed from the names and row numbers and uses FILTER to keep results to rows between +/-3 rows of where the target name is found. If you choose the first name (or any other name), you won't get an error; because even if the target name were on Row 1 and the formula goes looking for anything "greater than or equal to 1 minus 3, all rows will be greater than a negative number. Same on the high end. You just won't get a full seven names if there aren't at least three other rows prior to or after the target row.
this not the best solution but it will work , you can use a helper column 'D' that contains the following formula =if(countif(INDIRECT("B"&ROW()+3&":"&"B"&ROW()-3),"Andrew")>0,TRUE,FASLE)
and u can query from here like this SELECT * WHERE Column D = TRUE

Sorting a two column table into a multi-column table

I have a dataset that looks like this:
Attribute Value
A 1
B 2
A 5
B 7
C 2
D 9
A 4
B 2
C 4
I want to transform that into a sheet that looks like
A B C D
1 2 2 9
5 7 4
4 2
So I can feed it into a Box-and-whisker chart generator in Mac excel.
Any thoughts on the easiest way to do this? I may have to do it over and over. The dataset may consist of >100,000 rows, but a reasonable amount of attributes (e.g. less than 200).
This is for Excel 365.
In D1 enter:
=TRANSPOSE(UNIQUE(A2:A10))
In D2 enter:
=FILTER($B2:$B10,$A2:$A10=D$1)
Then copy D2 to E2 throughG2 (or beyond):

A function that will lookup a reference

Before I get started thanks for taking your time and helping.
This is what my worksheet looks like:
Row # B C D E F
2 1 Product 1 B2 B3 B4
3 2
4 6
5 1 Product 2 B5 B6
6 5
7 4 Product 3 B7
I was trying to follow this formula: (The best answer one or green check mark) return values from multiple matching rows
I got all the way to the =IFERROR(INDIRECT(lookups!H5),"") but can not get this to work.
What I am tying to do is order the numbers in Column B to go to the right of the product. Which I was able to get the column it is in (B) and the row number it is in (B2). I would like to change the value (B2) to the number that is there.
I would like it to look like this:
Row # C D E F
2 Product 1 1 2 6
3
4
5 Product 2 1 5
6
7 Product 3 4
If someone could help explain this to me or find a better way that would be great.
Not sure what is to happen to columnB but if you replace B with "="B throughout columns D:F then select each of these in turn and apply Text to Columns with Tab as the delimiter the 'cell references' convert to formulae referring to the values in B. If you want to delete columnB copy D:F and Paste Special, Values over the top.

How to fill cells from sheet A with values from sheet B when ID matches (in Excel)?

Consider the following 2 sheets. Sheet AAA has a list of companies with an emptry column ROA. Sheet BBB has a ROA value for some of these companies.
Sheet AAA
A B
1 ID ROA
2 1
3 2
4 3
5 4
Sheet BBB
A B
1 ID ROA
2 1 60.40
3 3 10.10
4 4 9.00
Looking at the ID in both sheets, I need a formula to fill in column AAA.B, resulting in
A B
1 ID ROA
2 1 60.40
3 2
4 3 10.10
5 4 9.00
What formula do I need in cell AAA.B2 (and down) to get this done? I believe VLOOKUP is the function appropriate here, but I am unsure as how to use it in this case?
Use the LOOKUP function with MATCH and ISNA:
=IF(ISNA(MATCH(A1,Sheet2!$A$1:$A$3,0)),"",LOOKUP(A1,Sheet2!$A$1:$A$3,Sheet2!$B$1:$B$3))

Excel - Combine multiple columns into one column 3

What is the formula that we can use in Microsoft Excel to get the result of the value summation from string column A and string Column C if they are the same? Column B and Column D are both the number that assign to its respective column which is Column A and Column C. For example “orange” holds the value 6 (in Column B) for Column A while in Column C “orange” hold the value 2 (in column D).Final results should show the summation of 6+2=8 (in Column F) for string ‘Orange’ (Column E).
Thank you
Lupe
If you have this table:
A B C D
orange 1 orange 6
apple 2 apple 7
grapes 3 carrot 8
carrot 4 melon 9
And you want to search in column C for each of the A column values, you should use this in column E: (for E2, and drag down)
=IFERROR($B2+VLOOKUP($A2,$C$2:$D$5,2,FALSE), 0)
make sure to change $C$2:$D$5 to your range (in both places).
A B C D E
orange 1 orange 6 7
apple 2 apple 7 9
grapes 3 carrot 8 0
carrot 4 melon 9 12

Resources