How to use variables?

Hello there,

Using metabase 0.25.2, we’ve had difficulties using Variables corrrectly. Every time we’ve tried on 0.25.2, the “Settings” tab stays greyed out.

Here’s the process i’ve followed:

  1. Click on the “New question” button
  2. create a new SQL query
  3. paste one of the following
  4. click on the “X” icon (Variables).

Queries tried:

select count(*)
from users
where country = {{ country}}
select count(*)
from users
where {{ country}}
SELECT count(*)
FROM userdata_metadata
WHERE 1 =1
[[AND country = {{ cat }}]]

Database: Postgres/RDS. Metabase is hosted on aws beanstalk.

Is this a known bug? What other info would you need to understand what happens ?

what browser are you on? the snippets you’re showing should bring up the variables pane

I think you’ve found a bug with a simple fix, @ni.paris: all you have to do is get rid of your leading/trailing spaces in the braces surrounding your variables’ names. I.e.,

select count(*)
from users
where country = {{country}}

or

SELECT count(*)
FROM userdata_metadata
WHERE 1 =1
[[AND country = {{cat}}]]

I’ve opened a github issue for this here:

I m using Chrome on MacOS

@maz : will try this fix and report

@maz I’ve checked and removing the spaces works. Thanks !

1 Like

Glad to hear it! Sorry about that. Hopefully we can get that issue fixed soon so others don’t run into this.