Using variables in a Metabase Custom Queston

Hi everyone.
ist there a posibility to use variables when creating a custom question in Metabase?
For example as part of a filter?

Thanks in advance.

Regards
Bostjan

Hi @bostjan
I don’t think I understand what you’re trying to do, but variables are possible in Native/SQL questions:
https://www.metabase.com/docs/latest/users-guide/13-sql-parameters.html

Hi @flamber

thanks for the prompt response.
Long story short. I switched to custom questions becase I was having problems with the “date” variale when using native/SQL.

This was my SQL query:

SELECT
date_trunc('DAY', STARTTIME),
USER as USER,
TRANSACTION as TRANSACTION,
sum(cputime)
from MY_TABLE
WHERE USER = {{user}}
AND TRANSACTION = {{transaction}}
[[AND STARTTIME between {{start_date}} and {{end_date}}]]
group by date_trunc('DAY', STARTTIME), user, transaction
ORDER BY date_trunc('DAY', STARTTIME) asc

When adding the results to the dashboard I am able to add the TRANSACTION and USER variable. Sadly I can not add the START and END DATE variable.

@bostjan You cannot reference parameters in Saved Questions - upvote by clicking :+1: on the first post on each issue:
https://github.com/metabase/metabase/issues/4367
https://github.com/metabase/metabase/issues/6449

I don’t know which column type STARTTIME is, or which Field Type you have defined it as in Admin > Data Model, but I’m guessing that’s what is causing you problems.