I have a spreadsheet in which I would like to return the text of all cells in MyTable field "Result" in which the corresponding text in MyTable field "Query" matches a string in $C$1, as a list. I want to do this using formulas. I know that my formula will need to have the following form:
=INDEX(MyTable[Result],SMALL(IF(MyTable[Query]=C1,ROW(MyTable[Result]),""),___))
The issue is that I'm not sure what should go in the ___. I want my formula to return strings from all relevant cells, not just a fixed number of cells, because I don't know now many cells match the criteria. As far as I understand, SMALL throws an error if the number provided as the last argument exceeds the number of non-empty strings returned by the IF function. Is there any way around this?
You k argument can be an array. And the upper bounds can probably be calculated using COUNTIF in your case.
Arrays can be constructed in a variety of ways.
One way (not the most efficient) would be something like:
=row(indirect("1:" & countif(MyTable[Query],C1)))
You can also use the INDEX function to construct the array, and, if speed is an issue, this would be better as it is a non-volatile function.
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.
I am trying to convert text of the month to the number
B2 cell:
BirthMonth_Jan
BirthMonth_Feb
BirthMonth_mar
BirthMonth_Apr
BirthMonth_May
BirthMonth_Jun, ect to december
for example, BirthMonth_Jan will output 1 based on the search of Jan, so i can compare this to another set of numbers
I have this, and tried this, but only works with two if statements, is there anyway i can do this with 12?
=(IF(ISNUMBER(SEARCH("sep",B2)),"9")),(IF(ISNUMBER(SEARCH("aug",B2)),"8")),(IF(ISNUMBER(SEARCH("jul",B2)),"7")),(IF(ISNUMBER(SEARCH("jun",B2)),"6")),(IF(ISNUMBER(SEARCH("may",B2)),"5")),(IF(ISNUMBER(SEARCH("apr",B2)),"4")),(IF(ISNUMBER(SEARCH("mar",B2)),"3")),(IF(ISNUMBER(SEARCH("feb",B2)),"2")),(IF(ISNUMBER(SEARCH("jan",B2)),"1"))
I get #Value!
If i try this, it also doesn't work
=IF(ISNUMBER(SEARCH("dec",B2)),"12",IF(ISNUMBER(SEARCH("nov",B2)),"11")),IF(ISNUMBER(SEARCH("DSH_KnowBe4_BirthMonth_Oc",B2)),"10"))
the second option only works with two but if i add more it throws an error
The questioner is trying to obtain a numeral equivalent to a partial month name extracted from a string. There are any number of examples in stackoverflow and the net generally on this theme. What is special in this case is the partial month name in the target cell, and use of the IF statement. The questioner is right to use search since it is not case-sensitive
Two formula are offered:
Formula 1
=(IF(ISNUMBER(SEARCH("sep",B2)),"9")),(IF(ISNUMBER(SEARCH("aug",B2)),"8")),(IF(ISNUMBER(SEARCH("jul",B2)),"7")),(IF(ISNUMBER(SEARCH("jun",B2)),"6")),(IF(ISNUMBER(SEARCH("may",B2)),"5")),(IF(ISNUMBER(SEARCH("apr",B2)),"4")),(IF(ISNUMBER(SEARCH("mar",B2)),"3")),(IF(ISNUMBER(SEARCH("feb",B2)),"2")),(IF(ISNUMBER(SEARCH("jan",B2)),"1"))
The questioner said "I get #Value!"
This is not a surprise because it is essentially a series of nine, self-contained, unrelated if statements, each separated by a comma. It is an invalid statement.
However, if the if statements were nested, then the formula would work. Something along these lines:
=IF(ISNUMBER(SEARCH("jan",B2)),"1",IF(ISNUMBER(SEARCH("feb",B2)),"2",IF(ISNUMBER(SEARCH("mar",B2)),"3")))
Formula 2
=IF(ISNUMBER(SEARCH("dec",B2)),"12",IF(ISNUMBER(SEARCH("nov",B2)),"11")),IF(ISNUMBER(SEARCH("DSH_KnowBe4_BirthMonth_Oc",B2)),"10"))
So close and yet so far... This statement uses the nested approach mentioned above. There is a major typo for the October search (instead of searching for "oct", the formula searches for "DSH_KnowBe4_BirthMonth_Oc") though this doesn't cause the formula to fail.
Failure is caused by two things:
1) The double bracket following "11")) in the "November" search. There should be zero brackets here.
2) The formula needs an additional closing bracket.
Two other things to note:
1) in the event of a match, the value returned is a string not an integer.
2) there's no provision to return a value in the event of a failure to match.
Working IF statement formula
The following formula, consisting of nested IF statements, works as intended by the questioner.
=IF(ISNUMBER(SEARCH("jan",B2)),"1",IF(ISNUMBER(SEARCH("feb",B2)),"2",IF(ISNUMBER(SEARCH("mar",B2)),"3",IF(ISNUMBER(SEARCH("apr",B2)),"4",IF(ISNUMBER(SEARCH("may",B2)),"5",IF(ISNUMBER(SEARCH("jun",B2)),"6",IF(ISNUMBER(SEARCH("jul",B2)),"7",IF(ISNUMBER(SEARCH("aug",B2)),"8",IF(ISNUMBER(SEARCH("sep",B2)),"9",IF(ISNUMBER(SEARCH("oct",B2)),"10",IF(ISNUMBER(SEARCH("nov",B2)),"11",IF(ISNUMBER(SEARCH("dec",B2)),"12",NA()))))))))))))
Note, the formula uses the NA() function to return #N/A if there is no match.
VLOOKUP alternative
Though the above-mentioned formula works, I find it complicated and inflexible. My preference in situations like this is VLOOKUP. My equivalent formula would be:
=VLOOKUP(RIGHT(B2,LEN(B2)-SEARCH("_",B2)),Sheet2!$A$2:$B$13,2,FALSE)
Using January as an example: BirthMonth_Jan, the formula lookup works like this:
RIGHT(B2,LEN(B2)-SEARCH("_",B2))
1) search for the underline character SEARCH("_",B2),
2) deduct the result from the total length LEN(B2)-SEARCH("_",B2) to give the number of characters to the right of the underline.
3) get all the characters to the right of the underline RIGHT(B2,LEN(B2)-SEARCH("_",B2)). This is the lookup value
4) Create a reference table on another sheet (refer screenshot); lookup this table and return column 2 (the number for that month).
5) If there is no valid result, VLOOKUP automatically returns #N/A.
The reference table on a separate sheet:
Not sure what you are trying to do with the formula but if your "BirthMonth_" text is consistent, you can use :
=MONTH(DATEVALUE("1 "&SUBSTITUTE(A12,"BirthMonth_","")&" 2018"))
Having a view of your data and expected result would help if this is not what you're after.
It is seems just possible what you might want is:
=MONTH(MID(B2,SEARCH("BirthMonth_",B2)+11,3)&0)
Returns a Number.
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.
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)),"")