I have a data base on Google sheet. See the spreadsheet at this link:https://docs.google.com/spreadsheets/d/1NGkH56Ga95osN8eBI6d5MhV7SnoEPK4Oe7ymRJVK7M0/edit#gid=1262146092 It s a copy so feel free to make any edit.
I am trying to filter information from the database using a query:
The filters are selected in the cell in yellow line 10 to 18 The query formula is in cell A22 and populates the lines and columns below. I want the formula to return information from the database that matches (L10 Option 1 or L10 Opt 2 …. L10 Opt 5) AND (L11 Opt 1 or.. or.. L11 opt5) AND… and so on until that last line. If “all” is selected in option 1, then it doesn’t filter on that criteria.
The formula below works for all lines, but not if "all" is selected (written only for the 1st 2 lines below):
=query('6. Database'!1:190,"select A,B,D,F,G,H,I,J,K,L,M,AD,BA,CD,CQ,CR,CU,CY,DE,FF,FM,FS where (D = '"&C10&"' or D='"&D10&"' or D='"&E10&"' or D='"&F10&"' or D='"&G10&"') and (E = '"&C11&"' or E='"&D11&"' or E='"&E11&"' or E='"&F11&"' or E='"&G11&"') ")
I tried this but it didnt work (formula parse error):
=query('6. Database'!1:190,"select A,B,D,F,G,H,I,J,K,L,M,AD,BA,CD,CQ,CR,CU,CY,DE,FF,FM,FS where ('"C10"'<>'all' and (D = '"&C10&"' or D='"&D10&"' or D='"&E10&"' or D='"&F10&"' or D='"&G10&"')) and ('"c11"'<>'all' and (E = '"&C11&"' or E='"&D11&"' or E='"&E11&"' or E='"&F11&"' or E='"&G11&"')) ")
The formula below work when "all" is selected but only for 1 line:
=query('6. Database'!1:190,"select A,B,D,F,G,H,I,J,K,L,M,AD,BA,CD,CQ,CR,CU,CY,DE,FF,FM,FS " & if(C10="all",, "where (D = '"&C10&"' or D='"&D10&"' or D='"&E10&"' or D='"&F10&"' or D='"&G10&"') "))
How can I get it to work with the option to select “all” in any line ?