Setting complex default values in the query is not working

Hello everyone,

trying to achieve simple scenario, but without luck. Creating a question and trying to use complex default value in the query:
SELECT
cohort_service_created_at_year
FROM
dwh_service
WHERE cohort_service_created_at_year = [[{{SelectYear}} #]]DATE_FORMAT(date_sub(NOW(),interval 1 day), "%Y")
group by cohort_service_created_at_year

Without input of Field Filter, where clause works fine, and shows correct (as expected) results, but once I put filter into, it shows:
" No results!
This may be the answer you’re looking for. If not, try removing or changing your filters to make them less specific."

Any ideas what could be wrong, or this is a known issue and will not work as excepted?

Thank you in advance.

Hi @Arvydas
Post "Diagnostic Info" from Admin > Troubleshooting.
You cannot use a Field Filter like that, since Metabase controls the column too.
https://www.metabase.com/docs/latest/questions/native-editor/sql-parameters
You would have to do something like this:

WHERE [[{{SelectYear}} #]] cohort_service_created_at_year = DATE_FORMAT(date_sub(NOW(),interval 1 day), "%Y")
1 Like

This is what I needed! Thanks!