Search code examples
checkboxgoogle-sheetsgoogle-sheets-formulagoogle-sheets-querygoogle-query-language

Google Sheets Query using Checkbox as search criteria


I want to use a query in Google Sheets that lets me look at a column of checkboxes to filter on ones that are checked (TRUE).

=QUERY(Available!$A$3:$O, "select A,B,C,D,E,F,G,H,I,J,K,L,M,N,O where O = '"& TEXT(TRUE) &"' and B > 100,000 order by B desc")

It is complaining of a literal value, but I am having a lot of trouble figuring out the proper syntax to ensure the query is reading the checkbox properly.


Solution

  • try it like this:

    =QUERY(Available!A3:O, 
     "where O = TRUE 
        and B > 100000 
      order by B desc")
    

    if the range is A:O and you want all columns you don't need select A,B,C,D,E,F,G,H,I,J,K,L,M,N,O

    also TRUE is boolean so no need to treat it as TEXT


    to fix ARRAY_LITERAL ERROR you need to build your formula like:

    ={IFERROR(QUERY(Available!A2:O, "select A,B,C,D,E,F,G,H,I,J,K,L,M where M like '%(Blah)' order by B desc"), 
      {"1","","","","","","","","","","","",""}); 
      IFERROR(QUERY(Available!A2:O, "select A,B,C,D,E,F,G,H,I,J,K,L,M where C = 'BlehBleh' order by B desc limit 7"), 
      {"2","","","","","","","","","","","",""}); 
      IFERROR(QUERY(Available!A2:O, "select A,B,C,D,E,F,G,H,I,J,K,L,M where O = TRUE and B > 100000 order by B desc"), 
      {"3","","","","","","","","","","","",""})}