Parameters are a quick and powerful tool in Tableau. One way to use parameters is to build a chart and allow a user to change a dimension or measure that is being viewed. It allows the dashboard creator to add more information using only one chart while providing dashboard users more intractability. This blog post will be using the superstore dataset as an example. Following along with this blog post to learn how to use parameters to swap out a dimension or measure in your chart on Tableau.

The chart we will be building in Tableau is a bar chart that shows the total sales or profit by region. We want to be able to give the dashboard user the option to either view sales or profit for different regions by changing the view in a parameter.

Here is a table of the data we want to represent:

Step 1. Creating a parameter

Create a parameter by clicking on it in the dropdown menu.

For this example, let’s name the parameter ‘Select value’. Now we want to create the different options we want to give the dashboard user. We will set the type to string select the list option. In the list below, we will now add the two viewing options which are to view sales or profit. Let’s click on the add button and type ‘Sales’. We will repeat this for profit. Now that we have the two view options, your parameter configuration window should look like this:

There are two ways to add the different categories. Firstly, you can add the categories automatically by clicking on the Add values from dropdown menu and selecting category. In this case, we do not have a data field that contains the viewing options. Alternatively, you can type out the values manually If you are working with a bigger list, consider using abbreviations in the value column and writing out the full name in the displayed as column to make typing the next step easier.

We want to ensure that the parameter we made is visible. To show the parameter, right-click on the parameter in the data pane and click on show parameter.

Now the parameter will be visible under filters on the right.

Step 2. Creating calculated field

In this next step, we will be creating a calculated field to build our chart and allow us to swap the two different measures. Click on the dropdown menu to create a new calculated field. When using parameters, we will be using the CASE function to swap out the view:

Step 3. Creating chart

The next step is to build out the dashboard. We’ll start by dragging the region dimension into the column shelf. Next, we’ll drag the calculated field we just made onto the row shelf.

We can polish up this chart further by adding some details by changing the y-axis value from ‘Parameter Value’ to either profit or sales. We can do this by right clicking on the y-axis label and clicking on edit axis.

Under Axis Titles in the configuration window, select the parameter we made (‘Select value’) in the dropdown. This option means that the title will dynamically change depending on what the user has selected in the parameter dropdown.

Lastly, let’s add a dynamic title to show ‘Profit by Region’ when we have selected profit and ‘Sales by Region’ when we have selected sales. To do this right click on the title and click on edit title.

Now when we change the parameter, our chart title will update to show.

You can view an interactable version of my Tableau Public.

Note: If your chart looks different, it may due to be a different Superstore datasets. In this example, the superstore dataset I used to create this blog was 2023.1 Superstore data.

The Data School
Author: The Data School