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
Right click in the Data panel and select Create a setting,
In the parameter creation dialog box, fill in the following information:
Name : Select a measure
Data type : String
Allow : List of values
Add values from the list for each measure:
sales
Profit
Quantity
Click on OK to finalize the creation of the parameter.
Step 2: Create a calculated field
Now right click in the Data pane and select Create a calculated field,
Name the field: Measure - Parameter
Enter the following formula:”CASE [Parameter name] WHEN “Sales” THEN [Sales] WHEN “Profit” THEN [Profit] WHEN “Quantity” THEN [Quantity] END”,
Click on OK to validate.
Step 3: Add the parameter to the chart
Add the field Choice Measure - Parameter In the Lines,
Add the field Sub-category in the Columns,
Show the setting by right-clicking on the parameter Select a measure in the Parameter panel,
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!