Bird
Raised Fist0
Tableaubi_tool~20 mins

Dynamic measure swap in Tableau - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
Dynamic Measure Swap Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ dax_lod_result
intermediate
2:00remaining
Dynamic Measure Swap Using Parameter Selection

You have a Tableau parameter named Measure Selector with values: Sales, Profit, and Quantity. You want to create a calculated field that dynamically returns the selected measure's value.

Which of the following calculated field formulas correctly implements this dynamic measure swap?

ADNE )]ytitnauQ[(MUS ESLE )]tiforP[(MUS NEHT 'tiforP' = ]rotceleS erusaeM[ FIESLE )]selaS[(MUS NEHT 'selaS' = ]rotceleS erusaeM[ FI
BIF [Measure Selector] = 'Sales' THEN SUM([Sales]) ELSEIF [Measure Selector] = 'Profit' THEN SUM([Profit]) ELSE SUM([Quantity]) END
CIF [Measure Selector] = 'Sales' THEN [Sales] ELSEIF [Measure Selector] = 'Profit' THEN [Profit] ELSE [Quantity] END
D
CASE [Measure Selector]
WHEN 'Sales' THEN SUM([Sales])
WHEN 'Profit' THEN SUM([Profit])
WHEN 'Quantity' THEN SUM([Quantity])
END
Attempts:
2 left
💡 Hint

Remember that you need to aggregate the measures inside the calculated field to work correctly in Tableau.

❓ visualization
intermediate
2:00remaining
Best Visualization for Dynamic Measure Swap

You have implemented a dynamic measure swap in Tableau using a parameter to switch between Sales, Profit, and Quantity. You want to create a dashboard that clearly shows the selected measure over time.

Which visualization type is best suited to display this dynamic measure swap effectively?

AA scatter plot with Sales on x-axis and Profit on y-axis
BA pie chart showing the proportion of Sales, Profit, and Quantity for the latest date
CA line chart with the date on the x-axis and the dynamic measure on the y-axis
DA stacked bar chart showing Sales, Profit, and Quantity side by side
Attempts:
2 left
💡 Hint

Think about how to best show changes over time for a single selected measure.

❓ data_modeling
advanced
3:00remaining
Data Model Considerations for Dynamic Measure Swap

You want to implement a dynamic measure swap in Tableau that allows users to select from multiple measures stored in different fact tables (e.g., Sales fact, Inventory fact).

What is the best data modeling approach to support this dynamic measure swap efficiently?

ACreate a union of all fact tables with a measure type column and a measure value column, then use this combined table for dynamic swapping
BCreate separate calculated fields for each fact table and use multiple parameters to switch between them
CUse blending to combine the fact tables at the visualization level and swap measures using parameters
DDuplicate the data source for each fact table and swap between data sources using parameters
Attempts:
2 left
💡 Hint

Think about how to unify measures from different tables into one structure for easy swapping.

🔧 Formula Fix
advanced
3:00remaining
Debugging Incorrect Dynamic Measure Swap Output

You created a calculated field for dynamic measure swap using this formula:

IF [Measure Selector] = 'Sales' THEN [Sales]
ELSEIF [Measure Selector] = 'Profit' THEN [Profit]
ELSE [Quantity] END

When you use this field in a view aggregated by month, the values are incorrect or missing.

What is the main reason for this issue?

AThe calculated field returns row-level values without aggregation, causing aggregation errors in the view
BThe data source does not contain the Quantity field
CThe ELSEIF syntax is invalid in Tableau calculated fields
DThe parameter values do not match the strings in the calculated field
Attempts:
2 left
💡 Hint

Think about aggregation requirements when using calculated fields in aggregated views.

🧠 Conceptual
expert
4:00remaining
Scenario: Performance Impact of Dynamic Measure Swap

You have a large dataset and implemented a dynamic measure swap using a parameter and a calculated field with multiple SUM aggregations. Users report slow dashboard performance.

Which approach will most effectively improve performance while keeping the dynamic measure swap functionality?

ARemove the dynamic measure swap and create separate dashboards for each measure
BPre-aggregate the measures in the data source or extract and use those pre-aggregated fields in the dynamic measure swap calculation
CReplace the parameter with multiple filters to reduce data volume dynamically
DUse table calculations instead of aggregations in the calculated field
Attempts:
2 left
💡 Hint

Think about reducing the amount of data Tableau processes at runtime.

Practice

(1/5)
1.

What is the main purpose of using a dynamic measure swap in Tableau dashboards?

easy
A. To create multiple charts for each measure
B. To automatically refresh data sources
C. To let users choose which measure to display on a single chart
D. To filter data based on user location

Solution

  1. Step 1: Understand dynamic measure swap concept

    Dynamic measure swap allows users to select which measure they want to see on one chart instead of showing all measures separately.
  2. Step 2: Identify the main benefit

    This makes dashboards interactive and saves space by avoiding multiple charts for each measure.
  3. Final Answer:

    To let users choose which measure to display on a single chart -> Option C
  4. Quick Check:

    Dynamic measure swap = user chooses measure [OK]
Hint: Dynamic measure swap means user picks measure shown [OK]
Common Mistakes:
  • Thinking it creates multiple charts instead of one
  • Confusing it with data refresh or filtering
  • Assuming it changes data source connections
2.

Which Tableau feature is essential to create a dynamic measure swap?

Choose the correct syntax to define it.

CASE [Parameter]
  WHEN 'Sales' THEN SUM([Sales])
  WHEN 'Profit' THEN SUM([Profit])
END
easy
A. Parameter with CASE statement to switch measures
B. Calculated field with IF statement only
C. Filter using fixed date range
D. Dashboard action to highlight marks

Solution

  1. Step 1: Identify the syntax used

    The code uses a CASE statement with a parameter to choose between measures like Sales and Profit.
  2. Step 2: Match feature to syntax

    This is the standard way in Tableau to create dynamic measure swap by switching measures based on parameter value.
  3. Final Answer:

    Parameter with CASE statement to switch measures -> Option A
  4. Quick Check:

    CASE + Parameter = dynamic measure swap [OK]
Hint: Dynamic swap needs parameter plus CASE statement [OK]
Common Mistakes:
  • Using IF without parameter for swapping
  • Confusing filters or dashboard actions with measure swap
  • Ignoring the need for a parameter
3.

Given the parameter [Select Measure] with values 'Sales' and 'Profit', and the calculated field:

CASE [Select Measure]
  WHEN 'Sales' THEN SUM([Sales])
  WHEN 'Profit' THEN SUM([Profit])
END

What will be the result if the parameter is set to 'Profit' and the total profit is 5000?

medium
A. 0
B. SUM([Sales])
C. Error due to missing ELSE
D. 5000

Solution

  1. Step 1: Understand parameter value effect

    The parameter is set to 'Profit', so the CASE statement returns SUM([Profit]).
  2. Step 2: Calculate output based on data

    Since total profit is 5000, the calculated field returns 5000.
  3. Final Answer:

    5000 -> Option D
  4. Quick Check:

    Parameter 'Profit' returns SUM([Profit]) = 5000 [OK]
Hint: Parameter value picks measure sum output [OK]
Common Mistakes:
  • Thinking missing ELSE causes error (it returns NULL instead)
  • Confusing measure names with values
  • Assuming default is zero without ELSE
4.

Identify the error in this dynamic measure swap calculated field:

CASE [Measure Selector]
  WHEN 'Sales' THEN SUM(Sales Amount)
  WHEN 'Profit' THEN SUM(Profit Margin)
END
medium
A. Missing square brackets around field names
B. Parameter name is incorrect
C. CASE statement syntax is invalid
D. SUM function cannot be used inside CASE

Solution

  1. Step 1: Check field name syntax

    In Tableau, field names must be enclosed in square brackets, e.g., [Sales Amount], [Profit Margin].
  2. Step 2: Identify error in code

    The code uses SUM(Sales Amount) and SUM(Profit Margin) without brackets, causing syntax error.
  3. Final Answer:

    Missing square brackets around field names -> Option A
  4. Quick Check:

    Field names need [ ] in SUM() [OK]
Hint: Always use [ ] around field names in calculations [OK]
Common Mistakes:
  • Omitting brackets around field names
  • Assuming CASE syntax is wrong
  • Thinking SUM can't be inside CASE
5.

You want to create a dashboard where users can switch between SUM([Sales]), AVG([Profit]), and COUNT([Orders]) using one parameter called [Measure Choice]. Which calculated field correctly implements this dynamic measure swap?

?
hard
A. CASE [Measure Choice] WHEN 'Sales' THEN SUM([Sales]) WHEN 'Profit' THEN AVG([Profit]) ELSE 0 END
B. CASE [Measure Choice] WHEN 'Sales' THEN SUM([Sales]) WHEN 'Profit' THEN AVG([Profit]) WHEN 'Orders' THEN COUNT([Orders]) END
C. SWITCH([Measure Choice], 'Sales', SUM([Sales]), 'Profit', AVG([Profit]), 'Orders', COUNT([Orders]))
D. IF [Measure Choice] = 'Sales' THEN SUM([Sales]) ELSEIF [Measure Choice] = 'Profit' THEN AVG([Profit]) ELSE 0 END

Solution

  1. Step 1: Check parameter values and measures

    The parameter has three values: 'Sales', 'Profit', and 'Orders'. Each must map to the correct aggregation.
  2. Step 2: Verify calculated field syntax

    CASE [Measure Choice] WHEN 'Sales' THEN SUM([Sales]) WHEN 'Profit' THEN AVG([Profit]) WHEN 'Orders' THEN COUNT([Orders]) END uses CASE with explicit WHEN for all three values and correct aggregations, matching the parameter choices exactly.
  3. Final Answer:

    CASE [Measure Choice] WHEN 'Sales' THEN SUM([Sales]) WHEN 'Profit' THEN AVG([Profit]) WHEN 'Orders' THEN COUNT([Orders]) END -> Option B
  4. Quick Check:

    CASE with all WHENs matches parameter values [OK]
Hint: Use CASE with all parameter options explicitly listed [OK]
Common Mistakes:
  • Using ELSE instead of explicit WHEN for all options
  • Using SWITCH which is not valid in Tableau
  • Mixing IF and CASE syntax incorrectly