Search code examples
if-statementgoogle-sheetsgoogle-sheets-formulaarray-formulasgoogle-sheets-query

Google Sheets Match / Query from Multiple Dynamic Dropdowns


I have a Sheet that I need to query data from another tab to match 4 if/or dynamic drop downs and 1 if/and dynamic dropdown. It's a stumper on my part. I've attached the sheet as well as a 4 min explanation video. Thanks in advance!

Sheet:

https://docs.google.com/spreadsheets/d/1rUtTJkvFKFI8Q6lnRtxNpky5bYe9u8BZBok0M8hwZ7o/edit?usp=sharing

Video:

https://www.loom.com/share/392fd41c5c0844d6ad7df308d1af9f6c


Solution

  • try:

    =ARRAY_CONSTRAIN(QUERY({'Sub List'!A2:AE, 
     TRANSPOSE(QUERY(TRANSPOSE('Sub List'!L2:U),,999^99)), 
     TRANSPOSE(QUERY(TRANSPOSE('Sub List'!V2:AE),,999^99))},
     "where "&TEXTJOIN(" and ", 1, 
     IF(B1="",,"Col32 contains '"&B1&"'"), 
     IF(B2="",,"Col32 contains '"&B2&"'"), 
     IF(B3="",,"Col32 contains '"&B3&"'"), 
     IF(B4="",,"Col32 contains '"&B4&"'"), 
     IF(B6="",,"Col33 contains '"&B6&"'"))&""), 999^99, 31)
    

    0


    for OR logic use:

    =ARRAY_CONSTRAIN(QUERY({'Sub List'!A2:AE, 
     TRANSPOSE(QUERY(TRANSPOSE('Sub List'!L2:U),,999^99)), 
     TRANSPOSE(QUERY(TRANSPOSE('Sub List'!V2:AE),,999^99))},
     "where "&TEXTJOIN(" or ", 1, 
     IF(B1="",,"Col32 contains '"&B1&"'"), 
     IF(B2="",,"Col32 contains '"&B2&"'"), 
     IF(B3="",,"Col32 contains '"&B3&"'"), 
     IF(B4="",,"Col32 contains '"&B4&"'"), 
     IF(B6="",,"Col33 contains '"&B6&"'"))&""), 999^99, 31)
    

    for combo (OR between yellow cells and AND for green cell)

    =ARRAY_CONSTRAIN(QUERY({'Sub List'!A2:AE, 
     TRANSPOSE(QUERY(TRANSPOSE('Sub List'!L2:U),,999^99)), 
     TRANSPOSE(QUERY(TRANSPOSE('Sub List'!V2:AE),,999^99))},
     "where ("&TEXTJOIN(" or ", 1, 
     IF(B1="",,"Col32 contains '"&B1&"'"), 
     IF(B2="",,"Col32 contains '"&B2&"'"), 
     IF(B3="",,"Col32 contains '"&B3&"'"), 
     IF(B4="",,"Col32 contains '"&B4&"'"))&")"&
     IF(B6="",," and Col33 contains '"&B6&"'"), 0), 999^99, 31)