Metabase Variable Filters for Postgres

I am running Metabase and PostgresSQL in Docker.

SQL query works fine. But its just Variable Filter in Metabase won't activate for my database.

select * from 
test_schema."Project" as pj 

where pj."Division" = {{"The Filter"}}

Any help here is really appreciated.

Thanks,

Hi @mcbenly

Post "Diagnostic Info" from Admin > Troubleshooting.

There's no quotes, spaces or dots in variable names. Just use {{the_filter}}

Please read these two articles:
https://www.metabase.com/learn/sql-questions/sql-variables.html
https://www.metabase.com/learn/sql-questions/field-filters.html

Thanks for your reply @flamber
Tried without quotes, but still no luck!

Here is the "Diagnostic Info" from Admin > Troubleshooting

{
"browser-info": {
"language": "en-US",
"platform": "MacIntel",
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:99.0) Gecko/20100101 Firefox/99.0",
"vendor": ""
},
"system-info": {
"file.encoding": "UTF-8",
"java.runtime.name": "OpenJDK Runtime Environment",
"java.runtime.version": "11.0.14.1+1",
"java.vendor": "Eclipse Adoptium",
"java.vendor.url": "https://adoptium.net/",
"java.version": "11.0.14.1",
"java.vm.name": "OpenJDK 64-Bit Server VM",
"java.vm.version": "11.0.14.1+1",
"os.name": "Linux",
"os.version": "5.10.104-linuxkit",
"user.language": "en",
"user.timezone": "GMT"
},
"metabase-info": {
"databases": [
"h2",
"postgres"
],
"hosting-env": "unknown",
"application-database": "h2",
"application-database-details": {
"database": {
"name": "H2",
"version": "1.4.197 (2018-03-18)"
},
"jdbc-driver": {
"name": "H2 JDBC Driver",
"version": "1.4.197 (2018-03-18)"
}
},
"run-mode": "prod",
"version": {
"date": "2022-04-07",
"tag": "v0.42.4",
"branch": "release-x.42.x",
"hash": "7c3ce2d"
},
"settings": {
"report-timezone": null
}
}
}

@mcbenly You can make normal queries via the GUI right?
Try creating a query like this - I can guarantee it works - there's millions of Metabase users.

select {{test}}

If you are planning on running Metabase in production, then make sure you set it up correctly:
https://www.metabase.com/docs/latest/operations-guide/running-metabase-on-docker.html#production-installation

Thanks @flamber
Yes, the test works fine. Thanks.

Thanks for the heads-up! currently testing out the functionality of Metabase. Will definitely run Metabase in production to see if the same issue. Will update if it is resolved.

Thanks for the quick turn-around by the way! really appreciate it.

@mcbenly Switching the application database will not change anything regarding how Metabase works. It will just avoid you losing all data if you deleted the container, since the H2 file is stored inside the container by default.

@flamber true! It's work now :slight_smile:

I think variable filter doesn't take spaces in the brackets.

Working query...

select * from
test_schema."Project" as pj
where pj."Division" = {{Filter}}