0
0
Tableaubi_tool~10 mins

Dynamic measure swap in Tableau - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a parameter that allows users to select a measure.

Tableau
CREATE PARAMETER MeasureSelector AS STRING DEFAULT '[1]' ALLOWABLE VALUES ('Sales', 'Profit', 'Quantity')
Drag options to blanks, or click blank then click option'
ASales
BProfit
CQuantity
DDiscount
Attempts:
3 left
💡 Hint
Common Mistakes
Using a default value not in the allowable values list.
Misspelling the measure names.
2fill in blank
medium

Complete the calculated field to swap measures dynamically based on the parameter.

Tableau
CASE [MeasureSelector] WHEN 'Sales' THEN SUM([[1]]) WHEN 'Profit' THEN SUM([Profit]) WHEN 'Quantity' THEN SUM([Quantity]) END
Drag options to blanks, or click blank then click option'
ASales
BProfit
CQuantity
DDiscount
Attempts:
3 left
💡 Hint
Common Mistakes
Using the parameter name inside SUM() instead of the field name.
Mismatching the parameter string and field names.
3fill in blank
hard

Fix the error in the calculated field to correctly handle the dynamic measure swap.

Tableau
IF [MeasureSelector] = 'Sales' THEN SUM([Sales]) ELSEIF [MeasureSelector] = [1] THEN SUM([Profit]) ELSE SUM([Quantity]) END
Drag options to blanks, or click blank then click option'
A'Quantity'
B'Profit'
C'Discount'
D'Sales'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a field name instead of a string in the condition.
Checking for the wrong measure name.
4fill in blank
hard

Fill both blanks to complete the calculated field that returns the selected measure's sum or zero if none matches.

Tableau
IF [MeasureSelector] = [1] THEN SUM([Sales]) ELSEIF [MeasureSelector] = [2] THEN SUM([Profit]) ELSE 0 END
Drag options to blanks, or click blank then click option'
A'Sales'
B'Profit'
C'Quantity'
D'Discount'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the order of measure names.
Using field names instead of strings.
5fill in blank
hard

Fill all three blanks to create a dynamic measure swap that covers Sales, Profit, and Quantity with a default zero.

Tableau
CASE [MeasureSelector] WHEN [1] THEN SUM([Sales]) WHEN [2] THEN SUM([Profit]) WHEN [3] THEN SUM([Quantity]) ELSE 0 END
Drag options to blanks, or click blank then click option'
A'Sales'
B'Profit'
C'Quantity'
D'Discount'
Attempts:
3 left
💡 Hint
Common Mistakes
Using field names without quotes.
Missing the ELSE clause for default value.