How do you create a dynamic measure in Tableau?

Let’s imagine that we work for a restaurant chain and are helping perform an analysis to figure out which items are under-performing. We’ll start with a visual like this (more on how to create tree maps here):

34-1.png

We’ve got a tree map displaying the 10 least profitable items. There isn’t an easy way to swap this out and see which are the bottom 10 items by sales without creating a new worksheet or swapping out every reference to profit. Additionally, if the end user is viewing the worksheet from Tableau Reader or Server, they may not have the ability to make these kinds of edits.

To provide that kind of flexibility to the end user we’ll want to create a parameter.

34-2.png

We’ll make sure the data type is String and then just type in the measures we want down below. The spelling and case sensitivity of those typed in values is important. We’ll be referencing them in a calculated field.

Next we’ll create a calculated field referencing that parameter that returns different measures depending on the parameter output.

34-3.png

After showing the parameter control, I’m going to replace all previous references to profit with references with this “Dynamic Measure” field.

34-4.png

After replacing the field, you may need to do a bit of configuring with the colors to get everything back to the way it was. You’ll also want to change the number format of the field at this point.

It would be nice if the subtitle could change to reflect whatever field was chosen in the parameter. This can be done by pulling up the text editor for the title and inserting the parameter text output where profit was previously.

34-5.png

Notice how the subtitle changes when the parameter is changed now:

34-6.png

Feel free to play with the workbook and download it here:

 

Need more help?  Sign up for a Tableau Office Hour to get expert help.