In the second week at Data School Down Under, we dived into Tableau Best Practices and advanced functionality around visualizations, calculations, parameters, mapping and much more. In this blog, I’ll take you through one of the many exercises that amazed me this week. It is controlling two views in a dashboard layout container using a parameter.
I have used an air pollution data set downloaded from www.ourworldindata.org.
- To begin with, we first need to have two views in our workbook. I have created two sheets showing the rate of change of pollution and death rate on a world map.
- We now need to create a parameter with String data type. I have named the parameter as Select Map View. Next, set the Allowable values to List. In the List of values, enter Pollution Level and Death Rate and click OK. Note that I have listed two values as I want to switch between two worksheets in my dashboard.
- Navigate to the first worksheet, right click on the Select Map View parameter and select Show Parameter Control. It will appear on the top right side of your worksheet. Change the view to Single Value List and change the selection to Pollution Level.
- Now for a parameter to work, we must use it in a calculated field. Right click on the parameter, select create calculated field and name it as Choose map view. It will already have the parameter name in the calculation. Click OK.
- Drag the Choose Map View calculated field to Filters and click the Pollution Level (PM2.5) checkbox. Click OK.
- Navigate to the second worksheet, right click on the Select Map View parameter and select Show Parameter Control. Change the view to Single Value List and change the selection to Death Rate.
- Drag the Choose Map View calculated field to Filters and click the Death Rate checkbox. Click OK.
- Now we need to create a dashboard and insert a title. I have named it as ‘How are the countries doing?’
- Drag a vertical container on the dashboard below the title.
- Now drag and drop the first worksheet tab into the layout container. Right click the sheet title and click Hide Title.
- Also drag and drop the second worksheet into the same layout container. Right click on the title and click Hide Title. Note that the parameter control will automatically appear on the dashboard since we had selected to show it on both the worksheets earlier.
- Click on the Menu dropdown on the parameter and choose Floating. This way you can choose its position on the dashboard. Do the same for legends if you want to show them too.
- And its done! Choose between Pollution Level and Death Rate to see the views change dynamically on the dashboard.