Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I select multiple different counts with different where clauses in Google Sheets query language?

I’m currently trying to select multiple counts with different criteria. Unfortunately, I am getting a PARSE error when I try to combine them into the same query. They work fine individually, just not together. Anyone know how to fix this?

This works fine (separately)

Select count(Col2) where Col2 <= 180 

or 

Select count(Col2) where Col2 > 180

or

Select count(Col2)

This doesn’t work (combined)

Select count(Col2) where Col2 <= 180, count(Col2) where Col2 > 180, count(Col2)

Error that I get when I try

Unable to parse query string for Function QUERY parameter 2: PARSE_ERROR: Encountered

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

you must use only one where

"select count(Col2) where Col2 <= 180 or Col2 > 180"

OR logic can be exchanged with AND logic if/when needed


try:

=INDEX(LET(a, A:B, {
 QUERY(a, "select count(Col2) where Col2 <= 180"), 
 QUERY(a, "select count(Col2) where Col2 > 180"), 
 QUERY(a, "select count(Col2)")}))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading