Searching for multiple words and using IF/OR/Vlookup function - excel

I'm trying to create a formula that will search a cell for the following words.. "Other" & "Repair" if either of these words are found I want it to be categorized as the word that is found. If none of these words are found I want the formula to Vlookup another column to then categorize it.
I got the formula to work for one search word, I cant figure out how to do it with two search words.
below is the formula I used for one word search criteria.
=IF(ISNUMBER(SEARCH("REPAIR",B9089)),"REPAIR",VLOOKUP(E9089,Key!$D:$E,2,0))
This is what I tried doing for the two search words but it breaks at the end for the true / flase statement
=IF(OR(ISNUMBER(SEARCH("REPAIR",B9090)),ISNUMBER(SEARCH("OTHER",B9090))),"REPAIR""OTHER",VLOOKUP(E9090,Key!$D:$E,2,0))

If you need to search for two values and the values returned, an OR statement will not work. Since it will only return true or false to an IF statement, and the IF will then return only one value. Instead, you can nest two IF statements inside each other for each of the values you need to find. Try the following formula:
=IF(ISNUMBER(SEARCH("Repair",B9089)),"Repair",IF(ISNUMBER(SEARCH("Other",B9089)),"Other",VLOOKUP(E9089,Key!$D:$E,2,0)))
(I am assuming your references and the Vlookup statement are correctly written by yourself)

I think you'll need nested IF statements, like this:
=IF(ISNUMBER(SEARCH("REPAIR",B9089)),"REPAIR", IF(ISNUMBER(SEARCH("OTHER",B9089)),"OTHER",VLOOKUP(E9089,Key!$D:$E,2,0))
What this does is first check if "REPAIR" is part of the speciified cell's value, if it isn't it checks if the cell value contains "OTHER", and if that is not the case it performs the desired VLOOKUP.
Please not that this is doable for two conditions, but if it starts getting to higher numbers you should consider writing a custom function in VBA.

Related

Data Validation using a conditional (IF) formula

I am building a spreadsheet to assign employees to work on projects based on their individual skills sets.
I have three named lists that contain the names of employees that are certified to work on different projects. I to use these lists as sources for dropdowns via Data Validation.
I am trying use the following formula in order to determine named listed appears in the dropdown:
=IF(SEARCH("ABC",A15),List_1,IF(SEARCH("DEF",A15),List_2,IF(SEARCH("GHI",A15),List_3_,List_4)))
However, Excel tells me that this formula evaluates to an error. I cannot find out why. Can someone point me to how to correct the formula? Or if there is a better way to have the lists populate based Cell A15's value?
Combine the SEARCH with the ISNUMBER function. SEARCH raises an error #VALUE! if it doesn't find the substring. ISNUMBER returns FALSE if it's argument returns anything other than a number. Finally, SEARCH returns an index number of what position in the string the substring was found, if one is found. Combine this knowledge to write: =IF(ISNUMBER(SEARCH("ABC",A15)),List_1,IF(ISNUMBER(SEARCH("DEF",A15)),List_2,IF(ISNUMBER(SEARCH("GHI",A15)),List_3_,List_4)))
Double check the parens I'm on my phone. GL.

Using results of If-Then statement in true clause

I am trying to use the value that returned true later on in an equation but am finding it difficult, if not impossible, to do so. This is what my formula looks like:
=IF(SUMPRODUCT(--ISNUMBER(SEARCH({"Application","Account","Machine"}, H5))),
INDEX(Sheet1!N$2:N$7,
MATCH(<term that made the SEARCH function true,Sheet1!M$2:M$7,0)), "")
I am trying to search a cell for a series of words, and if one of those words is found, use that word in an INDEX-MATCH search. Is there a way to do this or do I need to break my work up into two steps?
I think that you are after this:
=IFERROR(INDEX(Sheet1!N:N, MATCH(
INDEX({"Application","Account","Machine"},
MATCH(TRUE,ISNUMBER(SEARCH({"Application","Account","Machine"},H5)),0)),
Sheet1!M:M,0)), "")
Note that the inner INDEX/MATCH is what you were looking for, that is, returns from the array the keyword that exists inside the H5 sentence.

How to do an If Else in google sheets?

Right now I'm trying to figure out whether a cell contains one of two values, it will then perform an operation which depends on whatever value is in said cell. This is the function I have so far:
=IF(ISNUMBER(SEARCH("btc", I2)), (E2*(1+10%)-D2),""), IF((ISNUMBER(SEARCH("pp",I2)),E2-D2,""))
However I found that you cannot do 2 if statements in the same cell.
Put your second in the false of the first instead of the "". It is called nesting:
=IF(ISNUMBER(SEARCH("btc", I2)), (E2*(1+10%)-D2),IF(ISNUMBER(SEARCH("pp",I2)),E2-D2,""))
Alternate with nested IFERROR functions.
=IFERROR(E2*IFERROR(SIGN(SEARCH("btc",I2))*110%,SIGN(SEARCH("pp",I2)))-D2,"")

How to find a match in multiple array and array lookup?

I have some data that are in tables, i need to find a match in multiple array locations. If i'm looking for only one location i'm good, but if i need to find it in another location lets say, location!A6:J6 i get #value. Here my lookup.
=INDEX(location!A8:J8,MATCH(W_D!A6,location!A10:J10,0)) 'this is cell B6 formula *works fine
=INDEX(location!A6:J6&location!A8:J8,MATCH(W_D!A6,location!A4:J4&location!A10:J10,0)) 'Here is the issue.
*Note: one of my table is upside down as well.
You can use a concatenated or a nested formula. There are many ways to compose it but may be the easiest would be to combine many INDEX/MATCH combinations so that the result would be the one that matches the entry.
I will first describe the general method and then apply it to your case. You have a search formula that works correctly in one range, but you want to apply many searches in many ranges. There are two methods to achieve this in general:
Method 1: Concatenation
=IFERROR(search1, "") & IFERROR(search2, "") & IFERROR(search3, "")
Only the successful search will appear as a result of this concatenation. If non succeeds, result is blank. However, if many succeed, result will be their concatenation.
Method 2: Nesting
We can also nest the IFERROR statements. In general this is more complex to edit but it solves the problem of duplicate results.
=IFERROR(search1, IFERROR(search2, IFERROR(search3, "Not Found")))
I prefer Method 1 in your case since you know that your search wont have duplicate results.So we keep it simple and apply the concatenation method to your case:
=IFERROR(INDEX(location!A6:J6,MATCH(W_D!A6,location!A4:J4,0)), "") &
IFERROR(INDEX(location!A8:J8,MATCH(W_D!A6,location!A10:J10,0)), "")
With Method 2 the formula is:
=IFERROR(INDEX(location!A6:J6,MATCH(W_D!A6,location!A4:J4,0)), IFERROR(INDEX(location!A8:J8,MATCH(W_D!A6,location!A10:J10,0)), "Not Found")

simplifying Excel formula currently using INDEX, ROW, SUMPRODUCT and IFERROR

Does anyone have any brilliant ideas to simplify this difficult formula? Don't panic when you see it, I will try to explain.
=IFERROR(INDEX(rangeOfDesiredValues,(1/SUMPRODUCT((rangeOfSerials=$D20)(rangeOfApps=cfgAppID)(rangeOfAccessIDs=cfgAccessID)*ROW(rangeOfDesiredValues))^-1)),"")
Currently I am using SUMPRODUCT to do the equivalent of a VLOOKUP with multiple columns as criteria. Usually that only works with number results, but since I need to find text, I'm using SUMPRODUCT in combination with ROW and INDEX.
Unfortunately when no cell is found, my SUMPRODUCT returns 0. This causes the formula to return the incorrect cell rather than blank. For this reason I am running the result through this calculation:
(1 / result)^-1
This way results of 0 become an error, and other results remain unchanged. I feed this into IFERROR, so that errors become blanks.
Does anyone know how to make this neater? I am not able to create new columns in any of my spreadsheets.
It's always best to avoid using multi-condition summing functions like SUMPRODUCT when you want to find a single value (it would obviously give you an incorrect result or error if there's more than one row which matches all three conditions, I assume you expect one match at most here?). ROW function can also be problematic if you insert any rows in the worksheet.....
There are several approaches that can work. For a single formula, using MATCH is the most common - MATCH will only give the correct position or an error so no problems with zero values. That would look like this:
=IFERROR(INDEX(rangeOfDesiredValues,MATCH(1,(rangeOfSerials=$D20)*(rangeOfApps=cfgAppID)*(rangeOfAccessIDs=cfgAccessID),0)),"")
That's an "array formula" that needs to be entered with CTRL+SHIFT+ENTER......or you can make it into a regular formula with an extra INDEX function like this
=IFERROR(INDEX(rangeOfDesiredValues,MATCH(1,INDEX((rangeOfSerials=$D20)*(rangeOfApps=cfgAppID)*(rangeOfAccessIDs=cfgAccessID),0),0)),"")
A third alternative is to use LOOKUP which doesn't need "array entry"
=IFERROR(LOOKUP(2,1/(rangeOfSerials=$D20)/(rangeOfApps=cfgAppID)/(rangeOfAccessIDs=cfgAccessID),rangeOfDesiredValues),"")
That differs slightly from the previous versions in the case of multiple matches - it will give you the last match rather than the first in that scenario (but I assume you have only one match at most, as stated above).
Finally, if you don't mind using helper columns you could simplify the formulas considerably. Just use a "helper" column to concatenate the three criteria columns separated by dashes and then you can use a simple VLOOKUP or INDEX/MATCH, e.g.
=IFERROR(INDEX(rangeOfDesiredValues,MATCH($D20&"-"&cfgAppID&"-"&cfgAccessID,Helper_Column,0)),"")

Resources