Google Docs VLOOKUP ISERROR IF function - excel

Below is my excel function input but it does not seem to be working as it just returns -- in google docs.
=IF(ISERROR(VLOOKUP(F11,Formulas!$A2:$B17, 2, FALSE)),
VLOOKUP(F11,Formulas!$A2:$B17, 2, FALSE),
VLOOKUP(F11,Formulas!C2:D17, 2, FALSE))
Below is the information I am wanting to do a vlookup for.
A B C D
1 NYJ 27 PHI 20
2 BUF 13 DET 35
3 CIN 27 IND 10
4 MIA 24 NO 21
5 TB 12 WAS 30
6 CAR 25 PIT 10
7 ATL 16 JAC 20
8 NE 28 NYG 20
9 MIN 24 TEN 23
10 STL 24 BAL 21
11 CHI 16 CLE 18
12 KC 30 GB 8
13 DAL 6 HOU 24
14 DEN 24 ARI 32
15 SD 6 SF 41
16 SEA 22 OAK 6
Let's say a user inputs "GB" into cell F11. Point of the formula is to insert the points to the right of the GB. Formula is supposed to look for GB in the first column. IF it is TRUE, it will do a vlookup for the first column because it found GB in the first column. IF it is FALSE, it will do a vlookup for the 3rd column.
Not sure what is happening? FYI I did replace the last TWO vlookup functions in the formula with "TRUE" and "FALSE" and it worked as it should. Is this just a google docs issue?
Any help would be great! thanks
UPDATE
I tried this in excel and got a #N/A

As you are returning numbers an alternative here might be to use SUMIF, i.e.
=SUMIF(Formulas!A:C,F11,Formulas!B:D)
If F11 isn't found you'll get zero

Use IFERROR instead of ISERROR:
=IFERROR(VLOOKUP(F11,Formulas!$A2:$B17, 2, FALSE),VLOOKUP(F11,Formulas!C2:D17, 2, FALSE))

Your formula will always return #N/A with your current data. Your VLOOKUPs are good, but the issue is with the IF. Let me explain:
Let's call VLOOKUP(F11,Formulas!$A2:$B17, 2, FALSE) the function F1 and VLOOKUP(F11,Formulas!C2:D17, 2, FALSE) F2.
Your IF formula is:
=IF(ISERROR(F1),F1,F2)
Literally meaning: If F1 returns an error, use F1! If F1 does not return an error, use F2 (which by the way would now return an error).
Does this make sense? Try turning it around:
=IF(ISERROR(VLOOKUP(F11,Formulas!$A2:$B17, 2, FALSE)),
VLOOKUP(F11,Formulas!C2:D17, 2, FALSE),
VLOOKUP(F11,Formulas!$A2:$B17, 2, FALSE))
That should work now. You can also shortern it by using an IFERROR because you are repeating two operations:
=IFERROR(VLOOKUP(F11,Formulas!$A2:$B17, 2, FALSE),VLOOKUP(F11,Formulas!C2:D17, 2, FALSE))
Now it means if F1 gives an error, use F2, otherwise, use F1 itself.

Related

In spreadsheet (Excel or Google Sheets), how to find the sum of multiple values with multiple rows of column headers criteria?

as in the above picture, I need to sum all the values within the table C8:V22 which match
the first three characters of column B(orange),
row 5 for the number(blue),
row 6 for the first character(green),
row 7 for the first three characters(yellow)
The desire result would be the sum of the number in red, which is 10001 + 10081 + 10161 + 10221 = 40464
I tried many different ways to write the formula, one of that is:
=INDEX($B$5:$V$22,
MATCH($D$26,LEFT($B$5:$B$90,3),0),
MATCH(($F$26=$5:$5) * ($G$26=LEFT($6:$6, 1)) * (H26=LEFT($7:$7,3)), 0))
and pressed Ctrl+Shift+Enter to make it as an array formula, but couldn't figure out where is the error.
Anyone could help on this? Thank you!
Edit: The following is a simplify table for easy reference:
1
2
3
a1
a2
b1
abc1
abdf2
abc2
111a
11
12
13
222a
14
15
16
111b
17
18
19
555a
20
21
22
333d
23
24
25
111a
26
27
28
in this case, the match values are 11 + 17 + 26 = 54
I also tried using combinations of functions such as SUMIFS, SUMPRODUCT, search, e.t.c. but still not able figure out the solution.
In your sheet:
=SUMPRODUCT((LEFT(B8:B22,3)=C26&"")*(C5:V5=E26)*(LEFT(C6:V6,1)=F26&"")*(LEFT(C7:V7,3)=G26&"")*C8:V22)
simply retrieve the sum using your parameters and converting in string to match exactly.
If you have Excel 365 you can use this formula:
=LET(data,C8:V22,
ruleColumnB,LEFT(B8:B22,LEN(D26))=TEXT(D26,"0"),
ruleRow5,C5:V5=F26,
ruleRow6, LEFT(C6:V6,1)=G26,
ruleRow7, LEFT(C7:V7,3) =H26,
SUMPRODUCT(data*ruleColumnB*ruleRow5*ruleRow6*ruleRow7)
)
)
Using LET makes the formula more readable - esp. if you name the rules according to your special context.
If you don't have Excel 365 you have to replace the single parameters within SUMPRODUCT with each range/formula

count and sum function not properly working

I am working in excel and for some reason my sum or count function is not working properly. Or, perhaps I am not using the correct function or in the right way.
A B C D E F G H
February Max March Max
1 28
2
3
4
5
7
11
15
17
19
22
23
25
IF(SUM(A:A>0),28,"")
IF(SUM(E:E>0),31,"")
I have the above columns, I want the Max columns to show a specific number only if there is data in their respective month column. February has data, so it shows 28. March does not have any data so it shows no max. I need to look at the entire column or at least a large area (row 2 to row 2000).
The issue I am having is that if I do not have a value in the first row, but do have values in later rows, the sum or count function will to recognize that and will return zero.
A B
February Max
3
4
5
7
11
15
17
19
22
23
25
IF(SUM(A:A>0),28,"")
I have tried both sum and count functions, neither are giving me the results I want. I have also tried making >= 1. I found from StackExchange that someone was having a similar problem and a solution was to change the cell format to a number. That did not work either. Any suggestions?
Per my comment, you could use COUNTA() which checks if a cell is blank.
While it doesn't answer the technical reason SUM/COUNT isn't working, it should work for your intended purposes.
=IF(COUNTA(A:A)>0,28,"")

Excel how to look for value in table and return value from another cell

I have an issue in excel where I cannot get it to return a specific value.
I have a table of data like this
Week N1 N2 N3
w0 6 15 24
w1 5 8 9
w2 3 8 17
w3 20 23 31
w4 13 21 23
w5 6 12 15
w6 2 5 20
w7 10 20 21
the numbers in N1 N2 and N3 can change and are random.
What I need to be able to do is to lookup any number in the table and return the value in the weeks column.
so for example if I was looking for the number 20 it would return w6.
Ive tried various vlookups, Hlookups, Index and Match variations but just dont seem to be able to get this fairly simple thing to work.
Can anybody help me please, before I explode.
Try this:
= INDEX($A$2:$A$9,MATCH(1,MMULT(($B$2:$D$9=20)+0,{1;1;1}),0))
EDIT A slightly better formula:
= INDEX($A$2:$A$9,MATCH(TRUE,MMULT(($B$2:$D$9=20)+0,{1;1;1})>0,0))
It returns the first Week where a match is found in the table.
Obviously just replace 20 above with whatever value you want to look up.
See example below.
EDIT
More generally, instead of hardcoding {1;1;1} into the formula, you can make this dynamic, e.g.
= INDEX($A$2:$A$9,MATCH(1,MMULT(($B$2:$D$9=20)+0,TRANSPOSE((COLUMN($B$1:$D$1)>0)+0)),0))
Also, if you want to search the table from left to right instead of top to bottom, do this:
= INDEX($A$2:$A$9,MATCH(1,MMULT(TRANSPOSE((ROW($A$2:$A$9)>0)+0),($B$2:$D$9=20)+0),0))
Note, both of these are now array formulas (must be entered with Ctrl+Shift+Enter instead of just Enter.
Another method,
=index(A:A, iferror(match(G5, B:B, 0), iferror(match(G5, C:C, 0), match(G5, D:D, 0))))

Excel - Count of entries below cumulative threshold without helper column

I have the following little table. I'd like a formula that finds the number of values where the cumulative total (of column B) is less than some threshold (tx).
I tried
{=MIN((SUM(OFFSET(B1,0,0,A1:A17))>tx)*A1:A17)-1}
but OFFSET doesn't seem to be arrayable like that. Obviously, this would be trivial with a helper column, but for certain reasons that is not possible.
So the correct answer here should be 10.
tx = .8
A B
1 0.112106465
2 0.110981698
3 0.091959216
4 0.082163441
5 0.073292066
6 0.072407529
7 0.071646289
8 0.061646797
9 0.06011448
10 0.057566381
11 0.050341978
12 0.048227061
13 0.043207335
14 0.03940462
15 0.012914194
16 0.007603446
17 0.004417003
You're not really looking for a MIN; rather it should be MAX that follows your condition.
In E7 as a standard (non-array) formula,
=AGGREGATE(14, 6, ROW(1:17)/(SUBTOTAL(9, OFFSET(B1, 0, 0, ROW(1:17), 1))<D7), 1)
      
I prefer the following array formula** due to its non-volatility:
=MATCH(TRUE,MMULT(0+(ROW(B1:B17)>=TRANSPOSE(ROW(B1:B17))),B1:B17)>=0.8,0)-1
Regards
The most succinct way to do it I've found is
=SUM(--(SUBTOTAL(9,OFFSET(B1,,,A1:A17))<0.8))
entered as an array formula, or, equivalently,
=SUMPRODUCT(--(SUBTOTAL(9,OFFSET(B1,,,A1:A17))<0.8))

Excel - Lookup value in multiple columns

I have a datasheet with multiple columns that I want to search through - ending up with returning the top row value(s) in the found column(s). How to do this?
My idea would be to combine index with match, but I am rather lost for specific ideas...
January February March April May June
1 2 3 4 5 6
7 8 9 10 11 12
2 7 1 8 4 5
9 10 11 12 6 3
E.g. Search for: ID 3 - should return: March, June
Regards,
Nyborg
You need to add a VLOOKUP for each columns and after build the result
Following the Scheme:
A7 -> =IF(IFERROR(VLOOKUP($A$9;A1:A5;1;);"")="";"";A1) and autocomplete
D9 -> =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(CONCATENATE(A7;",";B7;",";C7;",";D7;",";E7;",";F7);",,";",");",,";",");",,";",")
D10 -> =IF(RIGHT(D9;1)=",";LEFT(D9;LEN(D9)-1);D9)
Formula for D9 & D10 it's only to have a good display of the results.
UPDATE Version:
Considering you agree to have the Row 7 ... You can simplyfy using the Result formula:
=INDEX(List;SMALL(IF(List<>"";COLUMN(List)-MIN(COLUMN(List))+1);1))&IFERROR(", " & INDEX(List;SMALL(IF(List<>"";COLUMN(List)-MIN(COLUMN(List))+1);2));"")&IFERROR(", " & INDEX(List;SMALL(IF(List<>"";COLUMN(List)-MIN(COLUMN(List))+1);3));"")
List it's the name Range of Row 7. The formula shall be apply with Ctrl+Shift+Enter.
This formula collect the first 3 value.
If you want more, add for each nth value you have:
&IFERROR(", " & INDEX(List;SMALL(IF(List<>"";COLUMN(List)-MIN(COLUMN(List))+1);3));"")
changing the last numer (in this case 3) and putting 4, 5, 6 ...
Obviusly if the result can be a lot, have few sense... Consider to use VBA !

Resources