How can I nest an vector index match function in an if statement? (Excel) - excel

I have the following vector function:
{=INDEX(Key!$K$2:$K$25,MATCH(TRUE,ISNUMBER(SEARCH(Key!$K$2:$K$25,V5)),0))}
This function returns what is in Key!$K$2:$K$25 if V5 is a match. This formula works. I would like to also make the function return, "Not Found", if the value searched for is not present in Key!$K$2:$K$25. I have tried the following, but it doesn't work. Could someone help?
{=IF(MATCH(TRUE,ISNUMBER(SEARCH(Key!$K$2:$K$25,V3)),0),INDEX(Key!$K$2:$K$25,MATCH(TRUE,ISNUMBER(SEARCH(Key!$K$2:$K$25,V3)),0)),"Not Found")}
Thanks.

simply merge your =INDEX(Key!$K$2:$K$25,MATCH(TRUE,ISNUMBER(SEARCH(Key!$K$2:$K$25,V5)),0)) with IFERROR
=IFERROR(INDEX(Key!$K$2:$K$25,MATCH(TRUE,ISNUMBER(SEARCH(Key!$K$2:$K$25,V5)),0)),"Not found")

Related

Why does this report #Value error in Excel

Just trying to report binary test...
=IF(FIND("RHS",B14),"RHS","LHS")
The function works for RHS, but reports #value for LHS. Why?
The FIND function returns the index of a string within another string, however, if the string you are looking for is not there it results in an error and displays "#value".
Likewise the if function is expecting an expression that results in a true or false value like: if ( this expression =true, then do this , otherwise do this)
Since the find function returns an error #value, it causes the if statement to also error out, when trying to calculate what to do.
To mitigate this you can wrap the function with either an ISNUMBER OR ISERROR function to validate if the find function is indeed returning an expected result
=IF(ISNUMBER(FIND("RHS",B14)),"RHS","LHS")
=IF(ISERROR(FIND("RHS",B14)),"LHS","RHS")
If expects a boolean result.
Find returns i9f it finds sowethig a number if Not showws an error that is why RDS works
A ISNUMBER returns suich a boolean result, that is needed
=IF(ISNUMBER(FIND("RHS",B14)),"RHS","LHS")

Why am I getting a value error in excel while using the ifs function?

=IFS(SEARCH("C*",A9),"Cake",SEARCH("K*",A9),"Cookies",SEARCH("B*",A9),"Bread & Bun",SEARCH("Y*",A9),"Pastry")
It works for the first criteria and returns "cake" but won't work for the others. I keep getting a #VALUE error.
Can help please??
SEARCH isn't a Boolean-valued function. It doesn't return FALSE if the string isn't found -- it returns a #VALUE! error which isn't coerced to FALSE.
What you could do is wrap everything like SEARCH("C*",A9) with ISNUMBER(): ISNUMBER(SEARCH("C*",A9)) since Excel can tell that #VALUE! isn't a number.

IF, OR and IFERROR function in excel

Column_A Column_B New (Expecting result for this situation)
#N/A #N/A Manual Posting
My function has problem for the last syntax"IFERROR(IFERROR(....)" . Currently, I get #N/A for the "New" column. However, I want to get "Manual Posting" instead.
My syntax:
=IF(OR(IFERROR(B1,A1)="Bank BPH",IFERROR(B1,A1)="GE Budapest Bank"),"GECapital",IF(IFERROR(B1,A1)="Avio Aero","GE Aviation",IFERROR(IFERROR(B1,A1),"Manual Posting")))
Ok, working it out I think I can explain.
IFERROR(x,y) returns value x, unless it's an error, then it returns y .. (even if it is an error).
You then take result of that, and compare it to a string:
IFERROR(A1,B1)="Bank BPH"
Assuming valid values, that expression will, of course, return TRUE or FALSE.
If both A1 and B1 are error, however, what happens ??
What is the result of:
#ERR="string" ??
answer: an error ...
so what does the IF do with an error? it's neither true, nor false.
You can simplify the situation to just this expression to see what's going on:
=IFERROR(A1,B1)="Bank BPH"
it returns an error.
Neither true nor false.
You're going to need another check condition for an error and how to handle it ..
perhaps:
=IF(AND(ISERROR(A1),ISERROR(B1)), "Manual post", IFERROR(A1,B1)="Bank BPH")
might do the trick ??
I think I figure out the correct syntax. I used to put the "AND(ISERROR(B18),ISERROR(A18)),"Manual Posting" to the end. However, I moved it at the beginning, it seems the problem can be solved.
=IF(AND(ISERROR(B18),ISERROR(A18)),"Manual Posting",IF(OR(IFERROR(B18,A18)="Bank BPH",IFERROR(B18,A18)="GE Budapest Bank"),"GE Capital",IF(IFERROR(B18,A18)="Avio Aero","GE Aviation",IFERROR(B18,A18))))

How do I sum results of two if statements in the same cell?

I'm looking to have the results of two If statements calculated and added in the same cell. I'm getting #VALUE! error.
=IF(ISERROR(GETPIVOTDATA("Sum of CHARGES",'Ship City'!$A$3,"ship_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29)),"",GETPIVOTDATA("Sum of CHARGES",'Ship City'!$A$3,"ship_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29))+IF(ISERROR(GETPIVOTDATA("Sum of CHARGES",'Recipient City'!$A$4,"recipient_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29)),"",GETPIVOTDATA("Sum of CHARGES",'Recipient City'!$A$4,"recipient_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29))
=IF(ISERROR(GETPIVOTDATA("Sum of CHARGES",'Ship City'!$A$3,"ship_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29)),"",GETPIVOTDATA("Sum of CHARGES",'Ship City'!$A$3,"ship_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29))
+
IF(ISERROR(GETPIVOTDATA("Sum of CHARGES",'Recipient City'!$A$4,"recipient_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29)),"",GETPIVOTDATA("Sum of CHARGES",'Recipient City'!$A$4,"recipient_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29))
Your both IF functions return an empty string "". Using + operator with strings returns #VALUE!. There are different methods to fix it:
use 0 instead of ""
use SUM instead of + (it ignores strings).
And as #John Bustos mentioned in his comment, you can simplify your formula with
IFERROR(value,value_if_error)
IFERROR description

excel vlookup with if functionc

For example:
F2 = VLOOKUP($L$2,sheet2!$A$2:$G$169,6,0)
I would like to add in the function that if $L$2 can not be found in the sheet2!$A$2:$G$169, then show "invalid".
May i know how should i modified to code in excel? Thanks.
First test what gets returned if $L$2 cannot be found by putting in a value you know is not in the search set. For example if it returns 0 then:
=IF(VLOOKUP($L$2,sheet2!$A$2:$G$169,6,0) = 0, "invalid", VLOOKUP($L$2,sheet2!$A$2:$G$169,6,0))
If it returns an error then try something along the lines of
=IF(ISERROR(VLOOKUP($L$2,sheet2!$A$2:$G$169,6,0)), "invalid", VLOOKUP($L$2,sheet2!$A$2:$G$169,6,0))
or just
=IFERROR(VLOOKUP($L$2,sheet2!$A$2:$G$169,6,0), "invlaid")

Resources