0
0
Tableaubi_tool~5 mins

Dynamic measure swap in Tableau - Step-by-Step Guide

Choose your learning style9 modes available
Introduction
Dynamic measure swap lets you change which measure shows in a chart without making new charts. This helps when you want to compare different numbers in the same view easily.
When your sales dashboard needs to show either revenue or profit based on user choice
When you want to let users pick which metric to analyze without cluttering the view
When you have limited space but want to show multiple measures interactively
When you want to create a single chart that can display different KPIs on demand
When you want to avoid duplicating worksheets for each measure
Steps
Step 1: Create a parameter
- Data pane → right-click → Create Parameter
A new parameter dialog opens
💡 Name it clearly, like 'Select Measure'
Step 2: Set parameter data type and allowable values
- Create Parameter dialog
Parameter options are ready for user selection
💡 Use String type and List of values like 'Sales', 'Profit', 'Quantity'
Step 3: Create a calculated field to swap measures
- Data pane → right-click → Create Calculated Field
Calculated field dialog opens
💡 Name it 'Dynamic Measure'
Step 4: Enter calculation using CASE or IF statement
- Calculated Field dialog
Calculation returns selected measure value
💡 Example: CASE [Select Measure] WHEN 'Sales' THEN SUM([Sales]) WHEN 'Profit' THEN SUM([Profit]) ELSE SUM([Quantity]) END
Step 5: Replace existing measure on Rows or Columns shelf with the new calculated field
- Worksheet view
Chart updates to show the measure chosen by the parameter
Step 6: Show parameter control
- Right-click parameter in Data pane → Show Parameter Control
Parameter dropdown appears on the worksheet for user interaction
Before vs After
Before
Worksheet shows a bar chart with SUM(Sales) only
After
Worksheet shows a bar chart that changes between SUM(Sales), SUM(Profit), or SUM(Quantity) based on user selection from parameter dropdown
Settings Reference
Parameter Data Type
📍 Create Parameter dialog
Defines the type of values the parameter can hold
Default: String
Allowable Values
📍 Create Parameter dialog
Controls what values users can select in the parameter
Default: List
Calculated Field Formula
📍 Calculated Field dialog
Defines how the selected parameter value maps to measures
Default: CASE
Common Mistakes
Not showing the parameter control after creating it
Users cannot change the measure without the control visible
Right-click the parameter and select 'Show Parameter Control' to make it interactive
Using the original measure instead of the calculated field in the view
The chart will not update dynamically because it still uses a fixed measure
Replace the measure on Rows or Columns shelf with the dynamic calculated field
Parameter values do not exactly match the CASE statement strings
The calculation will not return the correct measure values
Ensure parameter list values exactly match the text in the CASE or IF statement
Summary
Dynamic measure swap lets users pick which measure to display in one chart using a parameter.
Create a parameter with measure names and a calculated field that returns the chosen measure.
Remember to replace the measure in the view with the calculated field and show the parameter control.