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

Query function not working when I add WHERE in formula


When I use the query function in Google sheets it works fine until I try to add WHERE condition. I want to only pull data that contains a TRUE value in Column 10. Right now my query function can pull all of the data but when I try to add the WHERE condition the query does not pull any data even though there are TRUE values in Column 10.

I have tried using the WHERE condition to pull values from different columns and it has been unsuccessful. Anytime I try to add the WHERE condition in my query formula no data is pulled.

Below code works to pull all data:

=QUERY({RepTemplate1!A4:AC63;RepTemplate2!A5:AC64},"SELECT Col1, Col2, Col3, Col4, Col5, Col6, Col7, Col8, Col9, Col10, Col11",1)

Below code does NOT work to pull specified data:

=QUERY({RepTemplate1!A4:AC63;RepTemplate2!A5:AC64},"SELECT Col1, Col2, Col3, Col4, Col5, Col6, Col7, Col8, Col9, Col10, Col11 WHERE Col10 = 'TRUE'",1)

There is no error message for the formula that is not working. The headers appear just no data.

Not sure where I am going wrong.


Solution

  • or try FILTER:

    ={RepTemplate1!A4:K4; 
      FILTER({RepTemplate1!A5:K63; RepTemplate2!A5:K64},
             {RepTemplate1!J5:J63; RepTemplate2!J5:J64}=TRUE)}
    

    0