How to create a parameterized query in metabase

Hello. I am very new to Metabase and I’m having issues with creating parameterized visualizations using variables in SQL. The dashboard shows cannot display data. Then when i click on the tab and go a step deeper to the actual sql and enter the variable parameter it works properly. Only in that environment.

Please can someone guide me on how to show the variable on the dashboard itself without having to go into the SQL to change the variable. Thanks.

Check out this tutorial from the Metabase docs:

It’s important to consider about what happens if the variable is unset and is replaced with blanks. Use double square brackets to make clauses optional, [[like this]], or use a default value and don’t allow it to be unset.

Some databases (PostgreSQL) are picky about the data type of the variable and might need the value casted to the appropriate type.

If you need more info about the dashboard error, check the Metabase log. You should be getting a database exception that might point out what’s wrong with the query.

If you still can’t figure it out, post your query.

More reference information: