Nested IF,VLOOKUP Formula - excel

I am trying to write a formula to replace my results with a specific text if the returned results are either N/A, 0 or blank.
However, I can't seem to get it quite right. This is what I have so far.
IF(
LEN(
VLOOKUP($E3,'[Global Spend Categories SQL.xlsx]SQL Results USE'!$B$3:$I$4609,6,0)
)=0,"TO BE CATEGORISED",IF(LEN(
VLOOKUP($E3,'[Global Spend Categories SQL.xlsx]SQL Results USE'!$B$3:$I$4609,6,0)
)="","TO BE CATEGORISED",VLOOKUP($E3,'[Global Spend Categories SQL.xlsx]SQL Results USE'!$B$3:$I$4609,6,0)
)
)
My formula above is replacing the 0 and blank results with "TO BE CATEGORISED", however when I try to add in for N/A's it doesn't work.
Can anyone help with a solution to where I am going wrong?

Related

Excel lookup index that can return multiple results

I want to do an index lookup that can potentially return multiple results. I'm trying filter, and that doesn't seem to be working. Any suggestions?
My spreadsheet looks like this:
FinalResult tab:
A V
Index .... ErrorState
A1234 .... No results
A3400 .... #SPILL!
with V formula being: =FILTER(List_State_11.18.2021!A2:R81,List_State_11.18.2021!A2:A81=FinalResult!A2, "No results")
And the List_State_11.18.2021 tab looks like this:
A J
Device ... Display_Text
A1234 ... Not Found
A2345 ... Fault
A3400 ... Not Found
...
But every Device in List_state tab does not have Display_Text to find. Ie. Not every Index on the FinalResult tab has a fault to find in List_state. There's about 80 items in List_state with repeats for devices (multiple faults), and 300 indices in FinalResult with no repeats for index (exclusive). I want to return all faults found for each index, if found.
In my use of filter, it's finding all No results or #Spill!, with no other results. How do I fix what I have, or what other method can I use to find no, one, or multiple faults in my List_state tab, and put it in my FinalResult tab?
I checked, and the #spill! is not one with multiple matches. The index for the spill result is not in the List_state tab.
I've never done a lookup like this, so it's more than likely user error. Usually I do a vlookup where it's finding one device result and not multiple results. When I googled it, it seemed to suggest filter, but I could be mistaken. I haven't seen an example where the multiple results returned/found are put in the one row/column and not spilling to a second column like I want. I'm not convinced filter and my formula is ultimately what I need.
filter
multiple
Something like the following should work:
=LET(data, List_State_11.18.2021!J:J, filterlist, List_State_11.18.2021!A:A, lookup, A2, TRANSPOSE(FILTER(data, filterlist=lookup, "No Results")))
For use with TEXTJOIN, you wouldn't need to transpose the results
=LET(data, List_State_11.18.2021!J:J, filterlist, List_State_11.18.2021!A:A, lookup, A2, results, FILTER(data, filterlist=lookup,"NA"), TEXTJOIN("; ", TRUE, results))

Nesting 6 IF statements in excel 2017 and get the #NAME? error

Im trying to nest 6 IF statements in my excel spread sheet but I get the error #NAME? which I know is most likely a syntax error.
However I cant find the syntax error. I read online that you can nest up to 7 IF statements, does this not apply to Excel 2017?
Heres my function:
=IF(AND(F2=KWILA, B14=0.14), B38, IF(AND(F2=KWILA, B14=0.9), C38, IF(AND(F2=VITEX, B14=0.9), C39, IF(AND(F2=PINE, B14=0.14), B40, IF(AND(F2=PINE, B14=0.9), C40, IF(AND(F2=MACRO, B14=0.14), B41, H2))))))
Can someone help me please?
When combining functions in a formula, start simple, with a single function. Get it working and producing the result you want before making it more complex by adding a second function (or five more).
Since your question doesn't include an example of the data you're working with, I can't be sure of the issue, but I suspect you're trying to compare the text (strings) like KWILA to the cells (like A2).
If so, the problem is that text (strings) needs to be enclosed in "Quotation Marks".
Almost every time I more than 2 nested IF's, there's usually a more efficient way to accomplish the same thing.
In this cas, I split up the formula in Notepad to see what the goal is:
=IF(
AND(F2=KWILA, B14=0.14), B38
AND(F2=KWILA, B14=0.9), C38,
AND(F2=VITEX, B14=0.9), C39,
AND(F2=PINE, B14=0.14), B40,
AND(F2=PINE, B14=0.9), C40,
AND(F2=MACRO, B14=0.14), B41,
...if none of the above: H2
I encourage you to double check your criteria above - since, at first glance, it looks like a "broken pattern". For example there are two 38's, one 39, two 40's and one 41.
Assuming it's correct, I look for anything I can group, and I see that there are only 2 options for B14. So I regroup:
=IF(B14=0.14,
IF( F2=KWILA, B38
F2=PINE, B40,
F2=MACRO, B41,
IF(B14=0.9,
IF( F2=KWILA, C38,
F2=VITEX, C39,
F2=PINE, C40,
...if none of the above: H2
I also noticed that there are only 4 options for F2, so I considered using CHOOSE instead of IF but I'm not sure how B14 relates the the rest of the data (since it wasn't posted) so we'll stick with this simplification for now.
Midway through putting it "back together" I have:
=IF(B14=0.14,
IF( F2=KWILA, B38, if( F2=PINE, B40, if( F2=MACRO, B41, h2 ))),
IF(B14=0.9,
IF( F2=KWILA, C38, if( F2=VITEX, C39, if( F2=PINE, C40, h2 )))
h2 )
basically 2 set of IF statements. Note that I used H2 three times for "else confitions" -I'm not happy with this and I can almost guarantee there's a better way, but again, without seeing your data.....
Put back into a formula, we get a slightly more manageable:
=IF(B14=0.14,IF(F2="KWILA",B38,IF(F2="PINE",B40,IF(F2="MACRO",B41,H2))),
IF(B14=0.9,IF(F2="KWILA",C38,IF(F2="VITEX",C39,IF(F2="PINE",C40,H2))),H2))
I can't guarantee this will work since I wasn't able to test it, since... no data included in the question. You don't need to switch to this if your method works after adding the quotes.
There are still other alternate way this could have been simplified (and easier to understand or change later) which I won't get into now. Personally, I would have put the values in a table on another worksheet, and used INXDEX/MATCH to get the values I needed.
-

Can't find the right formula in Excel

I have 3 conditions based on this table: https://i.stack.imgur.com/GAeT0.png
Conditions are:
In column "Stadiu" (starting from D5) should type:
RIDICATA if the number from Populatie is > 1000 and the column Eveniment has Mondiala in it
MEDIE if the number from Populatie is > 500 or <= 1000 and the column Eveniment has Mondiala
MEDIE if the number from Populatie is > 500 and the column Eveniment has Internationala
SLABA = rest
I tried this formula:
=IF(AND(C5>1000;FIND("Mondiala";A5));"ridicata";IF(AND(C5>500;C5<=1000;FIND("Mondiala";A5));"medie";IF(AND(C5>500;FIND("Internationala";A5));"medie";IF(AND(C5<500);"slaba"))))
but it doesn't work.
I am new to Excel, so I hope you guys can help me what I am doing wrong. Thanks!
When evaluating the formula, anywhere that the FIND function doesn't find the string you're searching for, it returns a #VALUE error instead of 0 or FALSE. That's causing the whole formula to fail in those circumstances, so you need to handle those cases with IFERROR.
In addition, your nesting wasn't quite correct. You did not have an ELSE result for cases where all three tests failed. The following formula should return the expected results based on your criteria provided:
=IF(AND(C5>1000;IFERROR(FIND("Mondiala";A5);0));"Ridicata";IF(OR(AND(C5>500;C5<=1000;IFERROR(FIND("Mondiala";A5);0));AND(C5>500;IFERROR(FIND("Internationala";A5);0)));"Medie";"Slaba"))
Might be a little easier to relate it to your test criteria by spreading it out into sections:
=IF(
AND(
C5>1000;
IFERROR(FIND("Mondiala";A5);0)
);
"Ridicata";
IF(
OR(
AND(
C5>500;
C5<=1000;
IFERROR(FIND("Mondiala";A5);0)
);
AND(
C5>500;
IFERROR(FIND("Internationala";A5);0)
)
);
"Medie";
"Slaba"
)
)

Syntax for average if with OR and AND statements (example in body of Q)

I've come across an issue with AVERAGEIFS formula where they are unable to complete OR and AND simultaneously.
I'm working with data in the format below. I have one consistent criteria, in this example is "DF" in Column B. I have alternative criteria which can also be correct, "Dog*" or "Cat*" in Column A. In column C is the Cuteness Level.
Therefore, I am trying to work out the average cuteness level of Dogs and Cats with Vet Code DF with an Average If formula.
I've tried the following which doesn't work;
=AVERAGE(IF(OR(AND(A2:A17="Cat*",B2:B17="DF"),AND(A2:A17="Dog*",B2:B17="DF")),C2:C17, FALSE))
Can anyone please explain where I am going wrong?
Average IF
I couldn't figure out AVERAGEIFS with multiple wildcard conditions, but you can try something like:
= AVERAGE( IF( OR(Left(A2:A17,3)="Cat", Left(A2:A17,3)="Dog") * (B2:B17="DF"), C2:C17 ) )

Average not working with indirect formula and blank values

I have this formula:
=IFERROR(
(
(
IFERROR(INDIRECT($A6&"!$E$15");"")
+IFERROR(INDIRECT($A6&"!$E$29");"")
+IFERROR(INDIRECT($A6&"!$E$43");"")
+IFERROR(INDIRECT($A6&"!$E$57");"")
+IFERROR(INDIRECT($A6&"!$E$71");"")
+IFERROR(INDIRECT($A6&"!$E$84");"")
)
/6);"")
When any of these IDIRECTS return a blank value, I get an #VALUE! error (without the first IFERROR). Each individual line works just fine, and when putting them in cells individually, I can average them fine. If I remove the /6 part of this formula however, and wrap the lines with an AVERAGE-formula, I get the #VALUE! error also.
How can I proceed?
EDIT, SOLUTION FOUND (Thanks Mrig):
=IFERROR(
(
(
IF(ISNUMBER(INDIRECT($A7&"!$E$15"));INDIRECT($A7&"!$E$15");0)
+IF(ISNUMBER(INDIRECT($A7&"!$E$29"));INDIRECT($A7&"!$E$29");0)
+IF(ISNUMBER(INDIRECT($A7&"!$E$43"));INDIRECT($A7&"!$E$43");0)
+IF(ISNUMBER(INDIRECT($A7&"!$E$57"));INDIRECT($A7&"!$E$57");0)
+IF(ISNUMBER(INDIRECT($A7&"!$E$71"));INDIRECT($A7&"!$E$71");0)
+IF(ISNUMBER(INDIRECT($A7&"!$E$84"));INDIRECT($A7&"!$E$84");0)
)/
(
COUNTIF(INDIRECT($A7&"!$E$15");">=0")
+COUNTIF(INDIRECT($A7&"!$E$29");">=0")
+COUNTIF(INDIRECT($A7&"!$E$43");">=0")
+COUNTIF(INDIRECT($A7&"!$E$57");">=0")
+COUNTIF(INDIRECT($A7&"!$E$71");">=0")
+COUNTIF(INDIRECT($A7&"!$E$82");">=0")
)
);"")
The COUNTIF's bascially replaces the number "6" in the original code, and checks which of the INSNUMER's (instead of IFERROR's) that isn't blanks, so anything that's 0% or higher (actual value) will be counted, to get to the true average.
Using the suggestions above in the comments, you can use IF(ISNUMBER()) instead of IFERROR()
=IFERROR(
(
(
IF(ISNUMBER(INDIRECT($A6&"!$E$15"));INDIRECT($A6&"!$E$15");0)
+IF(ISNUMBER(INDIRECT($A6&"!$E$29"));INDIRECT($A6&"!$E$29");0)
+IF(ISNUMBER(INDIRECT($A6&"!$E$43"));INDIRECT($A6&"!$E$43");0)
+IF(ISNUMBER(INDIRECT($A6&"!$E$57"));INDIRECT($A6&"!$E$57");0)
+IF(ISNUMBER(INDIRECT($A6&"!$E$71"));INDIRECT($A6&"!$E$71");0)
+IF(ISNUMBER(INDIRECT($A6&"!$E$84"));INDIRECT($A6&"!$E$84");0)
)/6);"")
I started off thinking that your 'stagger' was 14 rows so I went with this array formula:
=AVERAGE(IF(MOD(ROW(E15:E84), 14)=1, IF(ISNUMBER(INDIRECT($A6&"!E15:E84")), INDIRECT($A6&"!E15:E84"))))
... but your 'stagger' is not a consistent 14 rows; the last gap is 13 rows so I modified it to this:
=AVERAGE(IF(ROW(15:84)={15,29,43,57,71,84}, IF(ISNUMBER(INDIRECT($A6&"!E15:E84")), INDIRECT($A6&"!E15:E84"))))
That produces a true average without zero substitution on blank cells while discarding text values.

Resources