This chapter will get you familiar with basic filtering functionality in Tableau. We will create a chart that shows name frequency across years, but we will then filter one name to see how its popularity has been changing over the years, and also narrow our view down to one state.
Adding filters
Getting ready
Connect to the Baby_names.csv dataset, and open a new worksheet.
How to do it...
- Drag and drop Year from Dimensions into the Columns shelf.
- Drag and drop Frequency from Measures into the Rows shelf.
- Drag and drop Name into the Filters shelf.
- In the search bar at the top of the list, start typing jac.
- Select Jacob, and click OK:
- We can see that the name Jacob has been gradually decreasing in popularity since 2010. Let's see how it has fared in Texas specifically. Drag and drop State from Dimensions into the Filters card.
- In the search box in the Filter [State] window, type tx.
- Select TX, click OK, and you will see the following results:
How it works...
Filters exclude rows from your dataset. When you select the name Jacob using a filter, only rows that contain the Jacob value from your dataset are analyzed, while all the other rows are excluded. You can also filter multiple values and select two, three, or 50 names to show in your view.
There's more...
One of the main advantages of Tableau filters is their interactivity. Let's execute the following steps to see how the Filter option works:
- If you hover over the Name: Jacob pill in the Filters shelf, a small white arrow will appear on it.
- Click on the arrow, and in the drop-down menu, click on Show Filter.
- A list of all the names will appear in the top-right corner of the worksheet. Only Jacob is selected, because that's how we set our filter. However, you can select and deselect any name(s) to change your visualization:
- If you hover over the filter control and click on the small black arrow that appears in the top-right corner, you can change the mode of the filter. You can choose whether you would like the filter to allow single or multiple values. You can also decide whether to implement the filter control as a drop-down list, checkboxes, or slider, as shown in the following screenshot:
See also
- For more information on filtering, see the Tableau Help page at https://onlinehelp.tableau.com/current/pro/desktop/en-us/filtering.html