How to change measures of a chart with a parameter in Tableau?

Preparation time: 10 minutes

Level of difficulty: Intermediate

Objective: Create a parameter to change chart measures

A common problem when creating dashboards is the multiplication of similar charts. For example, you want to follow the evolution of your sales, but also that of your profits or the quantities of products sold. In this article, we'll show you how to combine these three indicators into a single chart, giving the user the flexibility to select the metric they're interested in.

Required Data

  • 1 data table, Hypermarket (at the bottom of the Tableau Desktop login page),
  • Several measures, for example Sales, Profit, and Quantity,
  • 1 dimension, such as Sub-Category.

Step 1: Create the setting

  1. Right click in the Data panel and select Create a setting,
  2. In the parameter creation dialog box, fill in the following information:
    • Name : Select a measure
    • Data type : String
    • Allow : List of values
  3. Add values from the list for each measure:
    • sales
    • Profit
    • Quantity
  4. Click on OK to finalize the creation of the parameter.

Step 2: Create a calculated field

  1. Now right click in the Data pane and select Create a calculated field,
  2. Name the field: Measure - Parameter
  3. Enter the following formula:”CASE [Parameter name] WHEN “Sales” THEN [Sales] WHEN “Profit” THEN [Profit] WHEN “Quantity” THEN [Quantity] END”,
  4. Click on OK to validate.

Step 3: Add the parameter to the chart

  1. Add the field Choice Measure - Parameter In the Lines,
  2. Add the field Sub-category in the Columns,
  3. Show the setting by right-clicking on the parameter Select a measure in the Parameter panel,
  4. Test the setting.

Advice

It can be tricky to name your sheet when the measurement changes based on user choice. To ensure clear and understandable information, consider integrating the parameter directly into the chart title!