You may want to create a view that shows how the values of two measures compare against each other. But what if you also wanted to be able to choose which measures were being compared—or better yet, add a control to the view that would let any user select the measures to be compared. You can create such a view using parameters and calculated fields. The calculated fields replace the measures in the view and can be set interactively by the user with parameter controls or parameter actions.

There are 3 main steps to do this: Create a parameter, create a calculated field to measures in the view, and set-up the view. This example will use the same data from the Star Wars API from my Dashboard Week: Day 2 blog.

Step 1 – Create a parameter:

  1. In the Data pane, click the drop-down arrow in the upper right corner and select Create Parameter.
  2. In the Create Parameter dialog box, do the following:
    • Name the parameter (eg. “Select Measure”:)
    • Set the data type to string. (You can also select integer which can make it quicker to write the formula in the calculated field but this can be confusing for beginners)
    • Skip down to the allowable values field, and choose list.
    • Type individual measure names in the List of values area: eg ( “cost”, “speed”, “length”)
    • Click OK to close the Edit Parameter dialog box

***Pro Tip: If you want to create a second parameter simply right click the first and select duplicate.

Step 2 – Create a calculated field to change the measure in the view

  1. Choose Analysis > Create Calculated Field to open the calculation editor. Name the calculation and type or write the pictured formula
  2. Click OK to exit the calculation editor.

Step 3 – Set up the view:

  1. Drag one of the calculated fields to Rows and one to Columns
  2. Drag the dimension you want to Detail.
  3. In the Parameters area of the Data pane, right click the parameters you created and choose Show Parameter Control.
  4. Tableau displays the parameter controls beyond the right side of the view by default. Drag them over to the left side to make them easier for your users to see.

You can also use a similar method to this to change measure aggregations. Tune into the blogs to find out how to do this another time!

Thomas Maple
Author: Thomas Maple

Tom is an enthusiastic and determined member of The Data School. He previously worked as a network engineer for a wholesale ISP and even created his own virtual escape room business with colleagues during COVID lockdowns. Tom has completed an associate degree in Engineering Technology, as well as his bachelor and honours in Computer and Network Engineering at RMIT. He is always striving to upskill, achieving certifications such as Cisco CCNA, Juniper JNCIA. While at The Data School he has recently achieved his Alteryx Core certificate and is currently studying to achieve his Alteryx Advanced and Tableau Desktop Certified Associate certificate. Tom’s interests include sports (particularly AFL, he follows the Melbourne Football Club), horse racing, cooking (and eating), as well as outdoor activities such as camping, hiking and SCUBA diving.