How to add filters in Metabase questions

Ercan Vural
2 min readJul 10, 2019

Why?

  • After saving a question, you may need to filter table with specific parameter, like trying to gather data for specific city. In this case you will need to add this filter in Where clause and you need to edit city name, which is not very practical.
  • You may need this operation for multiple parameters, and it will take longer time.

How?

  • First of all we need to join all tables that we want to use as a parameter in filter.
  • Then we will define all filters in Where clause as below:

[[WHERE {{{country}} and {{city}} and {{category}} and {{date}}]]

  • Names in brackets are just name of filters, you can write whatever you want.
  • While doing it, you will realize that a window will appear at the right side of page.
  • You can open that window by clicking X icon at the right-top side of question as well.
  • Then we will fill each field with the instructions below:

Filter label: It will be visible as a name of filter. The names in query is the basic name of filter, not the visible one. So do not mix them.

Variable type: Choose Field filter option, which will let you to assign filter to a specific column in a table. It is useful because then you will see dropdown in filter when you type few letters already.

Field to map to: That’s the place where you will choose the column that will be used in filter. For example if you want to add city name filter, than you should assign it to a table that includes column with the list of those cities.

Filter widget type: You will have only one option here as Category. If you choose None, filter will not be visible.

Required?: If you enable it, you will have to use that filter.

Default filter widget value: When you open the question, you will always see the table filtered with that default value.

  • After doing all this configuration, you should see the filters visible at the top of question as below:

Looking for a productivity tool? Notion.so has everything you need:
https://affiliate.notion.so/sz2vffjwc8hp

--

--