How to use search function with if function - excel

My excel sheet have bank name, IFSC code and account number.
I want to get bank name from IFSC Code. For this I've used the following formula:
=IF(SEARCH("DNB",P17),"DELHI NAGRIK SEHKARI BANK",IF(SEARCH("SBIN",P17),"STATE BANK OF INDIA",IF(SEARCH("PUNB",P17),"PUNJAB NATIONAL BANK",IF(SEARCH("CNRB",P17),"CANARA BANK","TYPE BANK NAME")))).
It works for first option only (here, formula shows 'Delhi Nagrik Bank') and for other option it shows #Value.
Please tell me my mistake.?

I suggest you break your formula into its smaller component parts, and test those, to understand the root cause.
Understanding the problem
SEARCH("DNB",P17) returns a number if found, or an error if not found.
When that error occurs, the IF statement also returns an error. This is because IF expects input of either true or false only.
Also, this is why your formula works in the "DNB" case, but produces an error and doesn't actually test any further cases (e.g. "SBIN").
Solution
You need to update the function used in the IF statement's argument, so that it returns either a logical true or false value.
Conveniently, the ISNUMBER() function returns true if input is a number, and false otherwise.
TLDR
Instead of IF(SEARCH()), use IF(ISNUMBER(SEARCH())). Your formula will then work as intended.

Related

I got #num! error in my formula I used in Excel. I would like to ask where I got an error and What should I do?

I have an excel file that is populated with a lot of formulas. I am trying to populate the result by subtructing the latest value to the previous value and dividing the result given in the cell. Please see the photo below. As you can see, starting in row 6 i used the formula of:
"=ABS(IF(F7<=LARGE(IF(find3=$H7,$F$6:$F$196),10),(F7-LARGE(IF(find3=$H7,$F$6:$F$196),9))/E7,IF(F7<=LARGE(IF(find3=$H7,$F$6:$F$196),9),(F7-LARGE(IF(find3=$H7,$F$6:$F$196),8))/E7,IF(F7<=LARGE(IF(find3=$H7,$F$6:$F$196),8),(F7-LARGE(IF(find3=$H7,$F$6:$F$196),7))/E7,IF(F7<=LARGE(IF(find3=$H7,$F$6:$F$196),7),(F7-LARGE(IF(find3=$H7,$F$6:$F$196),6))/E7,IF(F7<=LARGE(IF(find3=$H7,$F$6:$F$196),6),(F7-LARGE(IF(find3=$H7,$F$6:$F$196),5))/E7,IF(F7<=LARGE(IF(find3=$H7,$F$6:$F$196),5),(F7-LARGE(IF(find3=$H7,$F$6:$F$196),4))/E7,IF(F7<=LARGE(IF(find3=$H7,$F$6:$F$196),4),(F7-LARGE(IF(find3=$H7,$F$6:$F$196),3))/E7,IF(F7<=LARGE(IF(find3=$H7,$F$6:$F$196),3),(F7-LARGE(IF(find3=$H7,$F$6:$F$196),2))/E7,IF(F7<=LARGE(IF(find3=$H7,$F$6:$F$196),2),(F7-LARGE(IF(find3=$H7,$F$6:$F$196),1))/E7,IF(F7<=LARGE(IF(find3=$H7,$F$6:$F$196),1),(F7-LARGE(IF(find3=$H7,$F$6:$F$196),1))/E7*(F7-LARGE(IF(find3=$H7,$F$6:$F$196),2))/E7)))))))))))"
In order to get the result of =(f7-f6)/e7. I added if functions cause there are some values that the lookup value is mentioned ($H7) below the table. When the lookup function was changed (please see the second photo), the formula was changed also into this:
"=ABS(IF(F15<=LARGE(IF(find3=$C15,$F$6:$F$196),10),(F15-LARGE(IF(find3=$C15,$F$6:$F$196),9))/E15,IF(F15<=LARGE(IF(find3=$C15,$F$6:$F$196),9),(F15-LARGE(IF(find3=$C15,$F$6:$F$196),8))/E15,IF(F15<=LARGE(IF(find3=$C15,$F$6:$F$196),8),(F15-LARGE(IF(find3=$C15,$F$6:$F$196),7))/E15,IF(F15<=LARGE(IF(find3=$C15,$F$6:$F$196),7),(F15-LARGE(IF(find3=$C15,$F$6:$F$196),6))/E15,IF(F15<=LARGE(IF(find3=$C15,$F$6:$F$196),6),(F15-LARGE(IF(find3=$C15,$F$6:$F$196),5))/E15,IF(F15<=LARGE(IF(find3=$C15,$F$6:$F$196),5),(F15-LARGE(IF(find3=$C15,$F$6:$F$196),4))/E15,IF(F15<=LARGE(IF(find3=$C15,$F$6:$F$196),4),(F15-LARGE(IF(find3=$C15,$F$6:$F$196),3))/E15,IF(F15<=LARGE(IF(find3=$C15,$F$6:$F$196),3),(F15-LARGE(IF(find3=$C15,$F$6:$F$196),2))/E15,IF(F15<=LARGE(IF(find3=$C15,$F$6:$F$196),2),(F15-LARGE(IF(find3=$C15,$F$6:$F$196),1))/E15,(F15-LARGE(IF(find3=$C15,$F$6:$F$196),2))/E15))))))))))"
But I've got a result of a #num! error. It's the same statement, the only difference is the looked up value. And when I try to show the calculation steps (Please see the third photo attached below), it says I've got an error in the first statement but why it was working on the first lookup value?
I am noob in excel. Please help me!!!
The reason for this error is that the LARGE function returns #NUM because the underlying array is empty / contains the FALSE result from your IF function (see here for details https://support.microsoft.com/en-us/office/large-function-3af0af19-1190-42bb-bb8b-01672ec00a64).
The reason here likely is that your find3=$C15,$F$6:$F$196 does not find a match.
Since we do not know what find3 is, you will need to look into the reason for that on your end (i.e., is there value of 5725 EGJ in your find3 data range? If not, why not? If yes, are you sure it spelled the same way (no leading spaces)?).
Once that is fixed you should be good to go.

How to use IF function with 3 arguments while ignoring blanks

Okay so my question is how do i use IF with 3 arguments while one of the arguments is "Ignore blanks".
If A1 is "Escalation_complaint or "Escalation_request" B1 must show "Escalated".
If A1 is any other text, B1 must show "Solved"
If A1 is blank, B1 must remain empty.
Can someone please help me figure this out?
Your first test must be whether the A1 is empty or not. This must be the first because if you test whether an empty string is contained in another string the answer is always yes. =SEARCH("","Something") returns 1. So, How do you test for an empty cell? I recommend Excel's COUNTA() function but you may prefer testing for "". So, let's say, your first test is this.
=IF(COUNTA(A1), True, False)
Some would say IF(COUNTA(A1)>0, True, False) and that is equivalent. The simple IF(COUNTA(A1) tests for non-zero. Any number other than zero returns True.
So, now you got your basic function. What's supposed to happen if the result is True? What do you want to happen if the result is False? The latter is easy. If the result is False you want a null string returns. So, now your formula looks like this:-
=IF(COUNTA(A1), True, "")
Observe that we simply replaced the False with the desired output. So, what do you want to happen if A1 has something in it, if the first test resulted in True? There are two possibilities. That makes the problem solvable with a single IF. IF A1 has something starting with "Escalation" in it the result should be "escalate", else it should be "solved". So, how do you test for cell content?
=Find("escalation", A1) will not find "Escalation" (with a capital E). Therefore I recommend SEARCH(), which does.
=SEARCH("escalation", A1) should return 1. If it returns 1 your problem is solved because if it returns any other number its not "escalated" but "solved". Unfortunately, there is a third option. It might return an error. In fact it will return an error every time the word isn't found. That gives you a 3-way possibility (1, bigger than 1, or Error) which can't be solved with a single IF. So, I suggest to avoid the error.
=Find("escalation", A1 & "escalation") will find the word "escalation" every time. But it will find it in first position only if the conditions for "Escalate" is met. Therefore the formula for the True condition in the basic formula must be this:-
IF(SEARCH("escalation", A1 & "escalation") = 1, "Escalated", "Solved")
That's it. Assemble the second IF into the first and you're done.
So, using two if(), and minimising the testing you need :
=IF(left(A1,3)="Esc","Escalated",IF(A1="","","Solved"))
Edit: Based on a comment to another answer, if testing for "esc" only could lead to problems then how about:
=IF(left(A1,5)="Escal","Escalated",IF(A1="","","Solved"))
Which will avoid words like "escaped" or "escargot"...
If you know that the text will always be Escalation_complaint or Escalation_request, you can do this with a nested IF query. =IF in Excel takes three parameters: what to verify, result if true, and result if false. You can have another IF statement in the what to do if it returns false section. We can also do an OR() statement to verify both Escalation_complaint and Escalation_request. The result looks like this:
=IF(OR(A1="Escalation_complaint",A1="Escalation_request"),"Escalated",IF(A1="","","Solved"))
The order here is important because you want the "for all other cases" to be in the final IF statement.
If you have a situation where you could also have "Request_escalation" or "complaint_escalation", you should make a more general solution that uses SEARCH or FIND which would allow you to do a more general lookup that allows for more values without having to hardcode them. Here is an example that makes it possible to find the word Escalation anywhere in the cell:
=IF(IFERROR(SEARCH("escalation",A1,1),0)>0, "Escalated", IF(A1="","","Solved"))
Excel have maximum 30 arguments in a formula.
= if (A1=1, "True",if(B1>2,"True", "false"))
Understand this pattern. easy way.
If you no longer understand this, or if your problem has not been resolved, attach a file or screenshot that relates to your problem.

MATCH function on Excel returns error

For some reason the MATCH function on excel returns an error.
Unfortunately I cannot share the data in order to replicate the problem but I was wondering if someone more experienced than I am could possibly find a small error in my code or something that I missed.
I used the functions according to these directions and I also I tried a solution here but neither source helped much.
=INDEX(IB_RAW!A2:L301,MATCH(1,(IB_RAW!$B:$B=IB!P10)*(IB_RAW!$D:$D=IB!A9)*(IB_RAW!$C:$C=IB!Q9)*(IB_RAW!$L:$L=IB!P7),0),IB_RAW!$J:$J)
I will try to describe the data as best as I can:
IB: The sheet where I want to show the extracted value
IB_RAW: The sheet where I get the information from
A2:L301: The whole dataset that I am using to look for the arguments
(in IB_RAW)
J: The value I want to extract (in IB_RAW)
The issue is with the MATCH function, as it returns #N/A, I've used the Show Calculation Steps... option to see where the problem is,
So for
(IB_RAW!$B:$B=IB!P10) returns TRUE
(IB_RAW!$D:$D=IB!A9) returns FALSE
(IB_RAW!$C:$C=IB!Q9) returns TRUE
(IB_RAW!$L:$L=IB!P7) returns TRUE
Therefore MATCH(1,0,0) but this returns #N/A instead.
Ok, The solution was from this detailed guide. It actually explains that you have to press Ctrl+Shift+Enter to activate the function and also I had to change the line of code a bit.
Hopefully this will be helpful to someone who wants to do the same thing like I did.
=INDEX(IB_RAW!I2:I301,MATCH(1,(IB_RAW!B2:B301=IB!P10)*(IB_RAW!D2:D301=IB!A9)*(IB_RAW!C2:C301=IB!Q9)*(IB_RAW!L2:L301=IB!P7),0))

is Excel function OR() incorrect?

Is there any reason in an Excel spreadsheet the expression OR(TRUE,#N/A) returns #N/A ?
How can we make it work the way we learned at school ie. OR(TRUE, whatever) should equal TRUE ?
so that we can evaluate a logical expression correctly even if not all parameters are known at the time of running, if those unknown are not really required.
Thank you
PS.
i use #N/A where the input is not known yet, it is not meant to be
an error. For instance
"=OR(turnover>1000000,leadtime>90,AND(turnover>500000,leadtime>30),AND(turnover>200000,leadtime>60))"
indicates an item needs special attention either because its
turnover is high or because its lead time is long but i don't
always have inputs for both. Sometimes one of two should suffice.
N/A is used when not known because i haven't found anything better than that. Tried "Unknown" string and AND(TRUE,"Unknown")
returns TRUE, which is not what it should be
i have many expressions which are more complicated than just
OR(x1,x2) so instead of trapping every parameter for error i have
written an udf OOR where OOR(TRUE,whatever even if error) = TRUE.
Just wondering if Microsoft has a better approach i don't know
You can wrap the logicals in an IFERROR that returns FALSE:
=IF(OR(IFERROR(A1=1,FALSE),IFERROR(B1=1,FALSE)),TRUE,FALSE)
You cannot compare to an error without throwing an error. Use ISERROR or ISNA on the cell to see if it contains an error.
=IF(OR(A1=TRUE,ISERROR(A1)), <something if true>, <something if false>)
In the above, you don't need to say A1 = TRUE, simply A1 will return true or false.

Excel ISNUMBER Function with IF Statement

I have an Excel file I'm working with. There is a column that contains numbers and text, sometimes it's just one or the other. I'm trying to write a function that scans the left most part of the cell to see if it starts with a number. I thought I had it but apparently not. This is what I had:
=IF(ISNUMBER(LEFT(E8,1)), "True", "False")
This continues to throw me a "false" result even though that particular cell, E8, begins with a "3". What am I missing here?
Try this out:
=IF(ISNUMBER(VALUE(LEFT(E8,1))),"True","False")
Using the IF statement is redundant. The most simple and effective way to achieve your desired result is:
=ISNUMBER(--LEFT(E8,1))
It will automatically return TRUE or FALSE
Note that you can achieve what you require with just the following:
=NOT(ISERROR(LEFT(E8)*1))
If you do not LEFT(E8) evaluates to LEFT(E8,1) and multiplication by 1 throws an error on anything non-numeric
If you need your output as strings then update as per below:
IF(NOT(ISERROR(LEFT(E8)*1)),"True","False")
EDIT
Using ISNUMBER() is a good alternative to NOT(ISERROR())
=ISNUMBER(LEFT(A1)*1)
=IF(ISNUMBER(LEFT(A1)*1),"True","False")
=IFERROR(IF(VALUE(LEFT(E8,1)),"TRUE","FALSE"),"FALSE")

Resources