0
0
Power BIbi_tool~10 mins

SWITCH function in Power BI - Interactive Code Practice

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

Complete the code to return 'High' when Sales is greater than 1000, otherwise 'Low'.

Power BI
SalesCategory = SWITCH(TRUE(), Sales > [1], "High", "Low")
Drag options to blanks, or click blank then click option'
A1000
B2000
C1500
D500
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number less than 1000 changes the category incorrectly.
Forgetting to use TRUE() as the first argument.
2fill in blank
medium

Complete the code to categorize scores: 90+ as 'Excellent', 70+ as 'Good', else 'Average'.

Power BI
ScoreCategory = SWITCH(TRUE(), Score >= [1], "Excellent", Score >= 70, "Good", "Average")
Drag options to blanks, or click blank then click option'
A100
B90
C60
D80
Attempts:
3 left
💡 Hint
Common Mistakes
Using 80 instead of 90 causes wrong categorization.
Placing conditions in wrong order.
3fill in blank
hard

Fix the error in the SWITCH function to correctly assign 'Low', 'Medium', or 'High' based on Quantity.

Power BI
QuantityLevel = SWITCH(TRUE(), Quantity <= 10, "Low", Quantity <= [1], "Medium", "High")
Drag options to blanks, or click blank then click option'
A15
B5
C20
D25
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number less than or equal to 10 causes overlap.
Using a number too high skips the medium category.
4fill in blank
hard

Fill both blanks to categorize Age into 'Child' (<=12), 'Teen' (<=19), or 'Adult'.

Power BI
AgeGroup = SWITCH(TRUE(), Age <= [1], "Child", Age <= [2], "Teen", "Adult")
Drag options to blanks, or click blank then click option'
A12
B18
C19
D20
Attempts:
3 left
💡 Hint
Common Mistakes
Using 18 instead of 19 excludes 19-year-olds from 'Teen'.
Swapping the blanks reverses categories.
5fill in blank
hard

Fill the blanks to assign product categories: 'Electronics' for code 1, 'Clothing' for 2, else 'Other'.

Power BI
ProductCategory = SWITCH(ProductCode, [1], "Electronics", [2], "Clothing", "Other")
Drag options to blanks, or click blank then click option'
A1
B2
C3
D4
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong codes swaps categories.
Not including a default value causes errors.