So, I have been trying to set parameters @DS_START_DATE and @DS_END_DATE to filter some data in Data Studio. The idea is to compare the year of a transaction with the year of the date selected by the parameter and create a column that saves the value of another one by using a CASE
WHEN
clause. The query extract goes as follows:
CASE
WHEN EXTRACT(YEAR FROM fechaTransaccion) = EXTRACT(YEAR FROM CAST(@DS_END_DATE AS DATE))
THEN VlrBruto ELSE 0 END AS VlrBruto_Actual,
CASE WHEN EXTRACT(YEAR FROM fechaTransaccion) = EXTRACT(YEAR FROM CAST(@DS_START_DATE AS DATE))
THEN VlrBruto ELSE 0 END AS VlrBruto_Anterior
I have tried adding a date filter on my data studio report and have already activated date parameters while doing the personalized consult and still is not working. When running the query in bigquery there's a box that says "Undeclared Query Parameters". While running in data studio the prompt says "unexpected consult error".
Any ideas how to solve it? Thanks in advance