I use the Google Sheets SQL-ish Query function to summarize data in a number of my spreadsheets. This has been working well for years, albeit slowly.
Today, I'm having problems with some of my queries - specifically with some that compare dates in the source data to TODAY()
.
To demonstrate, here's a link to a shared spreadsheet that I've used to reproduce the problem on fake data.
Edit: Example has been updated with AdamL's suggestion.
The source data is in range A1:D6
, with columns "Serial No.", "Type", "Location", and "Warranty Expiration". The last column is a date.
This function in A9
summarizes all data:
=query(A1:D6,"select B, count(A) group by B pivot C")
...like so:
Here's the thing. If I try to filter using WHERE
and DATE()
, the Query seems to break down completely. What I want is a table that looks like the one above, but including only data rows that have a date in column D
that is in the past.
=query(A1:D6,"select B, count(A) where D < now() group by B pivot C")
If I change the filter to something not involving dates, I get the expected output:
How do I get this to give me the summary I want?