0
0
Power BIbi_tool~20 mins

SWITCH function in Power BI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
SWITCH Function Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
dax_lod_result
intermediate
2:00remaining
Output of SWITCH with numeric expression
What is the result of this DAX measure?

Measure = SWITCH(2, 1, "One", 2, "Two", 3, "Three", "Other")
Power BI
Measure = SWITCH(2, 1, "One", 2, "Two", 3, "Three", "Other")
A"One"
B"Three"
C"Two"
D"Other"
Attempts:
2 left
💡 Hint
SWITCH compares the first argument to each value in pairs.
🎯 Scenario
intermediate
2:00remaining
Using SWITCH for category labels
You have a sales table with a column 'RegionCode' containing values 1, 2, or 3. You want a measure that returns "North" for 1, "South" for 2, "East" for 3, and "Unknown" otherwise.

Which DAX expression correctly implements this?
ARegionName = SWITCH(TRUE(), [RegionCode] = "1", "North", [RegionCode] = "2", "South", [RegionCode] = "3", "East", "Unknown")
BRegionName = SWITCH(TRUE(), [RegionCode] = 1, "North", [RegionCode] = 2, "South", [RegionCode] = 3, "East", "Unknown")
CRegionName = SWITCH([RegionCode], "1", "North", "2", "South", "3", "East", "Unknown")
DRegionName = SWITCH([RegionCode], 1, "North", 2, "South", 3, "East", "Unknown")
Attempts:
2 left
💡 Hint
Match the numeric RegionCode directly without TRUE() when comparing values.
🔧 Formula Fix
advanced
2:00remaining
Identify error in SWITCH with missing default
What error occurs when running this DAX measure?

Measure = SWITCH([Score], 1, "Low", 2, "Medium", 3, "High")

Assume [Score] can be 4.
Power BI
Measure = SWITCH([Score], 1, "Low", 2, "Medium", 3, "High")
AReturns blank for [Score] = 4
BReturns "High" for [Score] = 4
CSyntax error due to missing default value
DRuntime error due to unmatched value
Attempts:
2 left
💡 Hint
SWITCH returns blank if no match and no default is provided.
visualization
advanced
2:00remaining
Best visualization for SWITCH-based category measure
You created a measure using SWITCH to categorize customers into "New", "Active", and "Churned" based on purchase dates.

Which visualization best shows the count of customers per category clearly and accessibly?
AStacked bar chart with categories stacked vertically
BPie chart with distinct colors and labels for each category
CLine chart showing categories over time
DScatter plot with categories as point colors
Attempts:
2 left
💡 Hint
Think about showing parts of a whole clearly with labels.
🧠 Conceptual
expert
2:00remaining
SWITCH vs Nested IF performance and readability
Which statement best explains the advantage of using SWITCH over nested IF statements in DAX for multiple conditions?
ASWITCH improves readability and can be more efficient because it evaluates the expression once and matches values, unlike nested IF which evaluates each condition separately.
BNested IF is always faster because it stops evaluating as soon as a condition is true, while SWITCH evaluates all conditions.
CSWITCH and nested IF have identical performance and readability in all cases.
DSWITCH can only handle numeric comparisons, so nested IF is preferred for text.
Attempts:
2 left
💡 Hint
Consider how many times the expression is evaluated in SWITCH vs IF.