I'm using Google Sheet's QUERY function to import data from another tab, add two additional column 'Year' and 'Month' which are generated using column H
=QUERY(earnings!A:J, "SELECT A, B, C, YEAR(C), toDate(C) label YEAR(C) 'Year', toDate(C) 'Month' format toDate(C) 'MMM'", 1)
I want to filter the results to only show certain rows but I get an error when trying to add a WHERE clause to this query.
For example:
=QUERY(earnings!A:J, "SELECT A, B, C, YEAR(C), toDate(C) label YEAR(C) 'Year', toDate(C) 'Month' format toDate(C) 'MMM' where A = 'Brooklyn'", 1)
Returns an error
Unable to parse query string for Function QUERY parameter 2: PARSE_ERROR: Encountered " "where" "where "" at line 1, column 120. Was expecting one of: "options" ... "," ...
I've tried placing the WHERE clause different places but couldn't get it to work properly. How can I add it to this query?
Here's how my data looks like:
| Area | Amount | Date |
|---|---|---|
| Brooklyn | $500 | 01/02/2025 |
| Chicago | $600 | 01/03/2025 |
| Huston | $700 | 01/04/2025 |