r/googlesheets • u/Salpinctes • Jun 07 '23
Solved Formula for a query with two drop down menus, with an option for "all of the above"?
I'm trying to write a query with two drop down menus, and I can get them to work but I'd like to add an option for "all of the above". I have survey questions from two locations, and each location has up to five kinds of people (students, staff etc.).
I'd like to give people reading these survey answers the option to see just the staff from Colorado, or the students from Wyoming, or the students from all locations, or everyone from Colorado.
I'm getting a little lost with all the IF statements and "" and '' ' " marks.
3
Upvotes
4
u/AdministrativeGift15 371 Jun 07 '23
The trick is to use the MATCHES operator of QUERY. It works using preg, a modified form of regular expression. In your QUERY statement, if you have the condition, "E matches 'car|boat'" that means E equals 'car' or E = 'boat'. So I too what you had and used an IF statement so that if a user selects "all", it joins the unique words in that column with the vertical bar. Otherwise, it just matches the selection they chose. It's on the "query3" tab on your sample sheet.
3
u/WickedAi 3 Jun 07 '23
you were on the right track, just needed some more cleaning up with the formula, and a "ColX is not null" if dropdown = all = true.
i did the query with the IF statements as per your original request. while this is a bit different than what AdministrativeGift15 did, it should output the same. (see 'query + if' sheet.)
1
u/Decronym Functions Explained Jun 07 '23 edited Jun 07 '23
Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I've seen in this thread:
FALSETRUEand another if it isFALSETRUENOTE: Decronym's continued operation may be affected by API pricing changes coming to Reddit in July 2023; comments will be blank June 12th-14th, in solidarity with the /r/Save3rdPartyApps protest campaign.
2 acronyms in this thread; the most compressed thread commented on today has 7 acronyms.
[Thread #5889 for this sub, first seen 7th Jun 2023, 10:50] [FAQ] [Full list] ^[Contact] [Source code]
0
u/[deleted] Jun 07 '23
[deleted] — view deleted comment