Data Validation using a conditional (IF) formula - excel

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.

Related

Evaluate a range of strings based on a shorter list of strings (Excel 365)

While working on a method of filtering dynamic ranges, I came across an unexpected behavior of COUNTIF().
I wanted to evaluate a range (A2:A9) to see which lines match a shorter list in B2:B3. Useful for further use in FILTER(), SUMPRODUCT() and similar functions. Example below: go through a list on 9 stocks; mark the two stocks that are on the shorter list of 2; return a 9-item dynamic array of 1 and 0 in the same order as on the list of original 9 stocks.
An equivalent expression in Python would be plain vanilla iteration
if criteria_str in evaluated_range:
newlist.append(1)
else:
newlist.append(0)
I got what I wanted by using COUNTIF().
However I am completely confused about the order of arguments. Based on my past experience before Excel 365 enabled common functions to return dynamic ranges, I expected that [range] is A2:A9 and [criteria] is B2:B3. However, Excel assumes the opposite. "All items" are "criteria" (red) and "some items" are "range" (blue)?
Official Microsoft documentation for COUNTIF does not describe at all how dynamic arrays are handled. And for static operations, the order is the same it has always been - all items are "range", expression is "criteria".
Is this behavior (for this function, or all functions that return a dynamic array) documented anywhere?
It has always been that way.
COUNTIF(RangeToBeSearched,WhatToSearchFor)
COUNTIFS has always returned an array, it just did not spill like you see. For example =SUMPRODUCT(COUNTIF(B2:B3,A2:A9)) would have returned 2 regardless of the version you are using.
The second is the array of items to pass through the COUNTIFS. If you reversed them:
=COUNTIFS(A2:A9,B2:B3)
It would only "Spill" two lines because that is all there is in the second argument.
The first argument is the range to search and the second is what to search for. If there is more than one the COUNTIFS returns an array the size of the second argument.
To put it another way, your formula is the same as doing:
=COUNTIF(B$2:B$3,A2)
And dragging the formula down, but it just iterates for you. It has always been this way, you just did not "See" the results.
In older versions you could have highlighted C2:C9. Then put your formula in the formula bar and hit Ctrl-Shift-Enter and the results would spill like you see in Office 365.
Everything works in your formula as expected. You can use both =COUNTIF(B2:B3,A2:A9) and =COUNTIF(A2:A9,B2:B3) expressions depended on wanted result. With first you get your wanted result, simply you check every element in list A2:A9 if it appears in list B2:B3 and if it does, count it as 1. With second formula you would check how many times every element in list B2:B3 does appear in list A2:A9.
I have modified your list (added UBER to A10), maybe it will be easier to understand:

Searching for multiple words and using IF/OR/Vlookup 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.

Filtering a table with any combination of several search criteria

I've made a list of bars for my friends/coworkers and I want to add a tool that allows them to search for bars that match their preferred criteria.
The google sheet can be found here.
I want the user to be able to search based on the criteria they input on the left under "keywords". So this many be anywhere from 1, keyword to all 7 filled out. But I want it to search based on any combination.
I initially started with an INDEX/MATCH formula which only returned a single row.
I landed on the FILTER function after trying different options.
However, this does not ignore blank search terms. Cell D4 on the Search page has the current formula. This will filter by Area, and then Area and Category if both are filled out, but I have yet to figure out how to expand this to the remaining filters.
My current function is the following:
=IFERROR(IF(AND(LEN(B6),LEN(B7)),FILTER(AllInfo,Area=B6,Category=B7),FILTER(AllInfo,Area=B6)),"-")
The filter function does exactly what I want for one search criteria, but my attempts to include any combination of search terms have failed.
I have a number of named data ranges which reference their respective columns on the 'Toronto - BARS' sheet.
Feel free to share this list with any friends living in Toronto!
Edit: removed irrelevant information
The closest I got is the formula below, which requires you to replace the boolean values into "yes" and "no" (or any other string values):
=ArrayFormula(query({AllInfo},"select * "&if(counta(B6:B12)>0,"where ",)&join(" and ","Col"&(match(filter(A6:A12,B6:B12<>""), transpose('Toronto - BARS'!A1:I1),0))&"='"&filter(B6:B12, B6:B12<>"")&"'"),0))
2 improvements that could be made, but I didn't figure it out:
using the column names in the query, instead of column number
parsing the boolean values correctly and add or remove the single quotes accordingly, so it can support the current boolean values / checkboxes
==> I hope someone can pick that up and finish what I couldn't get done.

Excel: read text as string instead of regex

I'm somewhat new to excel and right now working on a sheet that simply counts the sales numbers of products.
I'm using the formula:
=COUNTIFS('salesreport'!$A$1:$A$1048576,'SalesNumbers'!$A1)
The salesreport sheet contains the data with product names in the A column, the SalesNumbers sheet contains a List of the product names in the A column and the mentioned formula in the second column.
Now to the Problem, some of the products have different variants and a * on the name ending e.g. "Product A*", "Product A large*".
Since the * is interpreted as any following text by Excel, the counter for "Product A*" will include the large variant.
Since I receive the data from outside its difficult to simply get rid of the * for future reports which should just be copy/pasted into the template.
The easy way to solve the problem is obviously to subtract the count of the large variant. The Problem I have with that is, that the formula is no longer consistent for all products and might cause problems if somebody beside me will work on the template.
Is there any way to make Excel read the name in the A column as a string instead of a regex?
Thank you in advance!
Ascani0
If I am understanding this correctly then you can use:
=SUMPRODUCT(--(salesreport!$A:$A=SalesNumbers!$A1))
Edit 2 SUMPRODUCT is powerful and pretty useful ARRAY formula which finds many usages. Here we use it to do specific COUNTIF like stuff.
salesreport!$A:$A=SalesNumbers!$A1 part tests equality
It generates boolean ARRAY of {TRUE,FALSE,TRUE....FALSE}
This result cannot be directly passed on to SUMPRODUCT which expects numeric data. So to achieve numeric coercion, we apply double unary (--) which can be also achieved by using +0 or *1 etc methods.
Edit And if you want to use COUNTIFS then you can use it like below:
=COUNTIFS(salesreport!$A:$A,SUBSTITUTE(SalesNumbers!$A1,"*","~*"))
Here tilde(~) does the work as escape character and allows checking of asterisk (*) in literal sense.

Excel 2010 If cell matches any part of string in list

I'm looking for a formula that can search a given list of strings and match a certain cell based on whether that cell contains text that appears in any part of a string from the list.
An example to show what I want to achieve:
Reference_List:
Some Product A
Another Example
(XYZ) FinalTest
ABC (Acronym Explanation)
List that I'm searching through:
FooBar
Another Example
QuickBrownFox
JumpedOverLazy Example
Acronym Explanation (ABC)
FinalTest (XYZ)
Ideal Matches Found:
Another Example
JumpedOverLazy Example (false positive but I would be okay with it)
Acronym Explanation (ABC)
FinalTest (XYZ)
So as you can see, it's testing the Search List against every sub-string in the Reference_List
Also, I don't mind if it contains false positives, but currently I'm running into too many false negatives with things like: (where List_REF is the name of cells e.g. A1:A20)
=SUMPRODUCT(--ISNUMBER(SEARCH(LIST_REF,A1)))>0
I've also looked at this example but I was unable to get it to work properly
Any help would be appreciated, Thank you
Edit:
Another Idea? Maybe if I could split each cell in the reference list into an array based on "spaces", then feed those arrays into the SUMPRODUCT function seen above that would search every cell by the sub array? Don't know how to do it but I'm gonna look into it
The below formula may be of help to you. With the Reference range column in A and the Search list in column G, apply this formula : =IFERROR(IF(EXACT(A2,G$2),G$2,IF(EXACT(A2,G$3),G$3,IF(EXACT(A2,G$4),G$4,IF(EXACT(A2,G$5),G$5,IF(EXACT(A2,G$6),G$6,IF(EXACT(A2,G$7),G$7,"")))))),"")

Resources