Have you ever found yourself in a situation where it seems like you need to create nearly identical copies of the same dashboard, with just one different variable? Maybe you have an Earnings dashboard, but you want to see the data for each city your business is in, or maybe you have a KPI dashboard that you want to see broken out by month.
Instead of creating duplicate dashboards, you can use dashboard filters to create simple toggles to change a variable for cards on a dashboard.
To add a filter to a dashboard, first click the pencil icon to enter dashboard editing mode, then click the Add a Filter button that appears in the top-right.
You can choose from a number of filter types:
The type of filter you choose will determine what the filter widget will look like, as well as which fields you’ll be able to filter your cards by:
When picking a Time filter, Metabase will prompt you to pick a specific type of filter widget:
Single Date and Date Range will provide a calendar widget, while the other options all provide slightly different dropdown interfaces for picking values. To get a widget that’s just like the time filter in the graphical query builder, choose All options.
There are four types of Location filters to choose from:
The ID filter provides a simple input box where you can type the ID of a user, order, etc.
The Other Categories filter is a flexible filter type that will let you create either a dropdown menu or an input box to filter on any category field in your cards.
Note: If you’re trying to filter Native/SQL questions, you’ll need to add a bit of additional markup to your query in order to use a dashboard filter with that question. For an in-depth article on this, check out Adding filters to dashboards with SQL questions.
Let’s add a filter widget to our dashboard. We’ll select a Time filter, and then select the Month and Year option.
Metabase will display a filter editing interface where you can wire up your new filter to each applicable card.
Each card will feature a dropdown menu where you can select the column to filter. The sidebar on the right displays the settings for the current filter. If there’s a card on your dashboard that you don’t want to use with the filter, or that doesn’t make sense to use with the filter, that’s okay — the filter will only be applied to the cards you select.
So here’s what we’re doing — when we pick a month and year with our new filter, the filter needs to know which column in the card to filter on. For example, if we have a Total Orders card, and each order has a
Date Ordered as well as a
Date Delivered column, we have to pick which of those columns to filter — do we want to see all the orders placed in January, or do we want to see all the orders delivered in January? So, for each card on our dashboard, we’ll pick a date column to connect to the filter. If one of your cards says there aren’t any valid columns, that just means that card doesn’t contain any columns that match the kind of filter you chose.
Before we Save our changes, we can use the right sidebar to customize the Label of our new filter, or set a Default value.
When you’re finished wiring up the filter, click Done at the bottom of the sidebar, then click on Save in the top right to save the dashboard with your new filter.
Once you’ve added a filter to your dashboard, just click on the filter to select a value and activate the filter. To stop filtering, just click the blue X.
You can also set up a dashboard question to update a filter on click.
If the column you’re using for a filter has more than 100 unique values, you’ll now automatically see a search box with autocomplete suggestions:
Columns with fewer than 100 distinct values will list all options:
In both cases, you can pick one or multiple selections for your filter.
If Metabase somehow picked the wrong behavior for your field, admins can go to the Data Model section of the admin panel and click on the gear icon by the field in question to specify a list, search box, or plain input box.
You can also link filters so that a child filter knows to limit its choices based on the activation of a parent filter.
Say you have two filters, one to filter by state, the other to filter by city. You can link the city filter to the state filter so that when someone filters by California, the city filter will “know” to only show cities in California. In this case, state is the parent filter, and city is the child filter.
To link filters, you’ll need to set up this parent-child relationship. And you set up this relationship through the child filter. In the above scenario, with a state and city filter, we’d edit the child filter, city, by clicking on the gears icon on the city filter. From the filter sidebar on the right, select the Linked filters tab.
Here you can limit the current filter’s choices. If you toggle on one of these dashboard filters, selecting a value for that filter will limit the available choices for this filter. In this case, we toggle on the state filter (the parent), to limit the choices for the city filter. When states are selected, the city filter will limit its choices to cities in those states. Click Done, then Save to save the dashboard.
Here are a few tips to get the most out of dashboard filters:
We’ll learn how to make our dashboards interactive.