Menu Close Get Metabase

Linking filters in dashboards

Nov 4, 2020 by The Metabase Team

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:

<em>Fig. 1</em>. A dashboard with a single filter for state.
Fig. 1. A dashboard with 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:

<em>Fig. 2</em>. The State filter is connected to all cards on the dashboard, in one case through the <strong>Person.State</strong> column, and in the rest via <strong>User.State</strong>.
Fig. 2. The State filter is connected to all cards on the dashboard, in one case through the Person.State column, and in the rest via User.State.

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:

<em>Fig. 3</em>. The same dashboard as in figure 1, filtered by the state of Wisconsin.
Fig. 3. The same dashboard as in figure 1, filtered by 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.

<em>Fig. 4</em>. Adding a new filter for <strong>Location</strong>.
Fig. 4. Adding a new filter for Location.

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 Person.City or User.City, depending on the card.

<em>Fig. 5</em>. Connecting each card to the <strong>City</strong> filter.
Fig. 5. Connecting each card to the City filter.

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:

<em>Fig. 6</em>. Nonsensical filter combinations yield no results: Austin is not a city in Wisconsin.
Fig. 6. Nonsensical filter combinations yield no results: Austin is not a city in Wisconsin.

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.

<em>Fig. 7</em>. Limit the City filters choices based on values selected for the State filter.
Fig. 7. Limit the City filters choices based on values selected for the State 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.

<em>Fig. 8</em>. Linked filters: the City filter knows to limit its choices based on the linked State filter's value.
Fig. 8. Linked filters: the City filter knows to limit its choices based on the linked State filter's value.

Further reading

Here are some more articles that cover working with filters:

You can also check out our documentation on Dashboard Filters.