MIP Logo

Using Parameters to Switch Measures in Tableau

This post was originally published on The Data School blog between 2018 and July 2025, before our program was renamed to MIP’s Analytics Career Accelerator. References throughout this article to “The Data School” or “DS” all refer to what is now MIP’s Analytics Career Accelerator. The program, its people, and its commitment to launching outstanding analytics careers remain the same – just under a new name.

If you are having trouble viewing this article, please report it here

You’re building a dashboard for a big project. You’ve uncovered dozens of interesting insights that should be shown off, but you don’t want to clutter your dashboard with repetitive bar and line charts. What do you do? Do you get selective with the insights and charts you present, or do you throw everything in? Either scenario risks you losing key insights or your audience’s attention. With parameters, you may be able to avoid this conundrum.

 

What are Parameters?

Parameters are essentially placeholder values that a user can choose to affect the behaviour of a visualisation. They can make your charts and dashboards more interactive and flexible in a variety of ways. This post will focus on using parameters as a dynamic tool for switching the displayed measure in a line chart, removing the need for multiple line charts, and making it easy for a user to locate relevant information.

 

Step 1: Create your parameter

In the Data Pane, click the drop-down arrow and select Create Parameter from the menu as shown.

A pop-up window will appear where you can name your parameter. To configure this window:

  • Set the Data type to String
  • Set Allowable values to List
  • Type the measures you want your users to choose from in the Value column.

The text entered in the Value column will automatically populate the Display As column and is what the user will see. You can change this text for a more user-friendly design, but remember the text in the Value column as this is what will be used in the next step to make the parameter work.

 

Step 2: Create your calculated field

In the Data Pane, click the drop-down arrow and this time select Create Calculated Field.

This calculated field could be made using an IF-THEN statement, but I like to use a CASE statement as shown below:

Here, your case statement will match the values in your parameter to the corresponding aggregate measures in the dataset. You’re basically creating a field that switches to the appropriate aggregate measure based on the user’s selection. Just remember the grey text has to match what you wrote in the Value column in the previous step.

Tip: Tableau automatically colours text within a calculated field to identify parameters, fields, functions, etc. This can help identify issues with your own calculated field.

 

Step 3: Create your dynamic visualisation

Right-click your new parameter at the bottom of the data pane and select Show Parameter. Drag your calculated field to the Rows shelf, then right-click and drag your date field to the Columns shelf. Ensure you use one of the continuous date truncations and not the discrete date part options (look here for reference).

 

Step 4: Rename your y-axis

At this stage, there is only one major, but easily fixable, issue with your chart – The y-axis label. Tableau will have labelled your y-axis with same name as your calculated field, but we want to ensure the label reflects the measure being displayed. To fix this, right-click the y-axis, select Edit Axis, locate the Axis Title section, and replace the Custom option with your parameter.

Now your chart axis should match the selected field in the parameter. This is a much cleaner way to present lots of data. Easy.

 

Share this post