google-sheetsgoogle-sheets-formulagoogle-query-language

Odd QUERY result in Google sheets?


I have a very simple query function in Google sheets, and I cannot understand why I'm getting the result it produces.

=QUERY(A4:C,"SELECT B WHERE A='Active' ")

It returns the data properly, except it also joins and transposes the first 64 entries of col B into the first cell of the query output. If I change the data range to A4:B, then the problem goes away, but I actually need it to extend past col C in the actual use case (I've pared down the data for the sample sheet). If I delete all of the data in col C the problem also goes away. I've also tried setting those rows to 'Inactive', but the problem persists. If I format col C as a number instead of automatic, then the problem goes away, but I still don't understand why it would cause this problem in the first place.

Why am I seeing what I do in E2?

https://docs.google.com/spreadsheets/d/1pqHNBojMc97VYHPoZ-FyI85Qv8vrKuHS6CS_trL2gqI/

Thanks.


Solution

  • Instead of

    =QUERY(A4:C,"SELECT B WHERE A='Active'")
    

    Use

    =QUERY(A4:C,"SELECT B WHERE A='Active'",0)
    

    If you omit the last parameter. It tries to guess it and sometimes it guesses wrong.