Hi,
We are trying to migrate to Metabase from a paid vendor and got stuck at filter usage. All of our questions are native query. We have multiple global field filters to be used at different questions. Is there a way to write global filters or should we define or rewrite field filters for each question?
Example:
Field filter:
country: select distinct country from table a
Question 1:
select *
from table b
where True [[and {{country}}]]
Question 2:
select *
from table c
where True [[and {{country}}]]
Regards,
Seckin
Hi @SeckinDinc
Currently you would have to do it via a join. Note that you cannot use table aliases, when using Field Filters:
https://www.metabase.com/docs/latest/users-guide/13-sql-parameters.html#the-field-filter-variable-type
select *
from table
left join country on country.id=table.country_id
where True [[and {{country}}]]
Thanks for the replay. I have this for a single table and it works. My problem is that should i do the same join for each table? When i do it for multiple tables i have multiple filters at dashboard. Even though i am using same labels they appear to be different filters.
@SeckinDinc I don’t know how you’re structuring your data, but you need to use a joined table (JOIN-clause) unless you’re using Field Filter on the main table (FROM-clause).
And then you would reference the same table and column in the variable sidebar of the Field Filter for all your questions.
Then you would only create a single filter on the dashboard, which you can connect to multiple cards/questions.
I would highly recommend that you have a look in the documentation:
https://www.metabase.com/docs/latest/users-guide/07-dashboards.html
https://www.metabase.com/docs/latest/users-guide/08-dashboard-filters.html
Hi flamber!
We’ve found the solution to our issue(s):
- setting up the same field type filter on each separate question
- no longer using aliases on tables that will be used as filters (as it’s not supported at the moment).
- Linking dashboard global filters to the specific filter of each one of these questions.