Metabase lets you link filters on dashboards so that the value plugged into one filter limits the options available to the linked filters.
Let’s walk through an example using the Sample Dataset included with Metabase. We’ll start with a dashboard on orders data that includes a single filter for state:
Let’s take a quick look under the hood so you can see how we’ve set up our State filter. Here’s our dashboard in Edit mode:
We’ve connected our State filter to each card on the dashboard. One thing to call out is that we can connect the State filter to multiple different state columns, and it just works. In this dashboard, we’ve connected the State filter to most cards by filtering on the column
User.State, except for the People map card, which filters on
Person.State. If we plug a value into the State filter, say WI for Wisconsin, the dashboard will update all the cards to display only the orders placed by people who live in the state of Wisconsin:
To link filters, we’re going to need another filter. So let’s say we want to add a filter to the dashboard for cities. On the dashboard, we’ll click on the pencil icon to enter dashboard edit mode, then click on the filter icon to add a new filter.
For What do you want to filter?, we’ll select Location. For What kind of filter?, we’ll select City.
With our City filter created, we can now wire it up by connecting each card to the filter. To do that, we select which column we want to filter by, which in our case is
User.City, depending on the card.
Once we’ve connected our cards to the new City filter, we’ll Save our changes.
And here’s where we’ll run into an issue. Right now, the filters are independent of each other. So the State filter will let us pick a state, say Wisconsin, and the City filter will let us select any city - including cities outside of Wisconsin. Basically, this dashboard will let us set up nonsensical filter combinations, like filtering for the city of Austin in the state of Wisconsin, which is not how our universe is currently set up. As expected, this combo of filters yields no results:
We can prevent people from creating these nonsensical filter combos by linking the filters. For example, if someone chooses Wisconsin in the State filter, the City filter should “know” to limit the options for cities to only those within the state of Wisconsin.
To link the two filters, we’ll click on the pencil icon to return to dashboard edit mode. Since we want the City filter to react to a change in the State filter, we’ll want to change the settings on the City filter. We’ll click the gears icon on the City filter to bring up the settings sidebar for the City filter.
Here’s the important part: in the sidebar, we’ll click on the Linked filters tab, which presents us with options to limit this filter’s choices, i.e., the City filter’s choices.
Metabase will list the available filters that we can link the City filter to (figure 7). In this case, there’s only one filter, the State filter, so we’ll toggle that filter to “on” to link the filter.
Let’s Save our changes, and try it out.
With the City filter linked to the State filter, when we plug in WI for the state filter, we’ll see that the City filter now knows to only show cities in Wisconsin.
Here are some more articles that cover working with filters:
- Field Filters: create smart filter widgets for SQL questions
- Adding filters to dashboards with SQL questions
- Create filter widgets for charts using SQL variables
You can also check out our documentation on Dashboard Filters.