=QUERY('Sheet8'!A:Z;"select A, B where 'Year' = 2016")
I have this query and I wanted to make the year part dynamic so I tried this
=QUERY('Sheet8'!A:Z;"select A, B where 'Year' = year(now())+4")
But that didn’t work so even tried saving the values in cells and the referencing them in the were clause like where 'Year' = Sheet!B1 but that didn’t work either. How can I create a where statement that looks performs an operation before doing the comparison?
=QUERY(‘Sheet8’!A:Z;select A, B where ‘Year’ = 2016) I have this query and I wanted
Share
The
year()function in the QUERY select clause is a scalar function that must reference one of the columns. So if the column of dates is in column A, you would usewhere year(A) =etc.To make it dynamic, it is best (IMO) to concatenate a value generated from spreadsheet functions (rather than the select clause, which doesn’t seem to generate according to the spreadsheet time zone). So something like:
=QUERY('Sheet8'!A:Z;"select A, B where year(A) = "&(YEAR(NOW())+4))