Using parameters to select different measures

by Edoardo Aversa
Photo by Stephen Dawson | Unsplash

In Tableau, parameters are a great way of visualising selected values of a given dimension (or measure); an example would be a parameter that highlights the values Furniture, Office Supplies and Technology from the dimension Category in the Sample – Superstore dataset. However, what if we want a parameter to choose between two or more measures (e.g. sales and profit) and not between the values of a single dimension/measure?

We can do that by applying a parameter to a whole worksheet following the usual steps: creating the parameter, using it in a calculation and using that calculation in our worksheet.

Creating the parameter

Let’s say that we want to look at sales and profits in Nordic countries using a map. The first step is configure the parameter as shown below:

Select String as Data type, select List as Allowable values, then Fixed and - under Value - write down the options you want displayed in your parameter. Then click OK.

Using the parameter in a calculation

Now create a calculated field and simply select the parameter name as shown below:

Then click OK.

Use the calculation in the worksheet(s)

In our example, double click on Country/Region, drag Sales onto Colour, drag Region onto Filters and select North; finally, click on the parameter and select Show Parameter. You should have a worksheet similar to this one:

Right now, selecting the values on the parameter will not change anything in the view, since our calculated field is not in the worksheet yet.

Before dragging and dropping the calculated field though, we need to make sure that we selected the correct option in the parameter card on the right: if we have sales displayed in our worksheet then select Sales in the parameter; if profit then Profit, and so on. We need to do this because we are going to drag and drop our calculated field (Profit/Sales) onto filters and the only value available will be the one previously selected in the parameter (regardless of how many values in total can be selected in the parameter). Once you get the option below, tick Sales and click OK.

By doing so, we are basically associating the entire worksheet with the value selected in the parameter; therefore the two need to match.

After having done so, we need to repeat the same process for our profit worksheet (build the worksheet -> select Profit in the parameter -> drag and drop the calculated field onto filters and tick Profit).

Now, create a new dashboard and drag and drop a horizontal container, as well as our two worksheets inside the container. Finally, hide the titles of both sheets and our dashboard will be ready to go. Selecting the different options in the parameter will 'squash' the deselected worksheet(s) and leave only the selected one in the view.

Hope you found this useful!