The following query is breaking for me in Google sheets, and I can’t determine what I’m doing wrong:
=sum(query(B:E, “SELECT E WHERE C = ‘”&S6&” AND B <= date ‘”&TEXT(R6, “yyyy-mm-dd”)&”‘”, 0))
(I want to return the sum of the values in column E where C is equal to the number in column S, and B is less than or equal to the date in column R. In other words: I want to sum up the numbers in column E before a given date for each name provided.)
Currently I’m getting the following error:
Google Sheets Error screenshot
However, when isolating only the ‘WHERE C = X’ and ‘WHERE B <= date’ I am not having any issues. The following queries work just fine:
=sum(query(B:E, “SELECT E WHERE C = ‘”&S6&”‘”, 0))
=sum(query(B:E, “SELECT E WHERE B <= date ‘”&TEXT(R6, “yyyy-mm-dd”)&”‘”, 0))
But combining them with an AND is giving me a PARSE_ERROR. Anyone have any ideas or suggestions? Thanks!
I expected combing the two queries with an AND would work fine but it isn’t. I’m not sure if I’m missing a syntax error or if there’s a correct way of accomplishing what I’m trying.
Isaac F is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.