Limit content of dropdown list filter

Hi,

I have a dashboard made of several visuals based on SQL query. I created multiple variables to be able to add filters in my dashboard. All my variables are setup as field filters. All linked to some fields available in my query.
My problem is that Metabase show all possible field value in my filters dropdown list.

For example, if i have a restriction in my SQL query to limit data to only customers based in Belgium and France, I will still have all the country in my filter dropdown list. And for example the ability to select Germany, selection that will show no result as datas are already filtered to show only Belgium and France.

How can I limit my filter dropdown list content to existing values ?

Thanks for your support.

Hi @Fagan
You cannot control the options shown currently:
https://github.com/metabase/metabase/issues/5245 - upvote by clicking :+1: on the first post
Unless using Linked Filters: https://www.metabase.com/learn/dashboards/linking-filters

Hi @Fagan,

I just was solving same issue. One solution might be to add a sub-condition that refers to pre-build table or materialized view. Pattern is:

...
where
 exists(
        select * from measures
        where
            "testName" = main_view."testName"
            [[and {{test_name_var}}]]
    )

You then map the field filter {{test_name_var}}to the "measure" materialize view that contains only the limited number of values for the drop down.

1 Like