

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 2
click for more info
Not enough gems
Cost: 6 gems
1: DAX
incomplete
2: Logical Functions – IF
incomplete
3: SWITCH Function
incomplete
4: Time Intelligence Functions
incomplete
5: More Time Functions
incomplete
6: Add Columns
incomplete
7: Aggregations
incomplete
8: Aggregations As Measures
incomplete
9: Iterators
incomplete
10: Calculated Columns vs. Measures
incomplete
11: Context in DAX
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
The SWITCH function is like a more powerful IF. It checks multiple conditions and returns different values based on which condition is true. Here's an example that classifies homes into "Small," "Medium," or "Large" based on the SquareFeet column:
OrderSize =
SWITCH(
TRUE,
Homes[SquareFeet] <= 2000, "Small",
Homes[SquareFeet] <= 3000, "Medium",
"Large"
)
You might be wondering, "Why the TRUE at the beginning of the SWITCH function?" It's a bit odd, and it usually will just be TRUE, but it's specified because you can change it. It's just the value that the following conditions need to match. In this case Homes[SquareFeet] <= 2000 and Homes[SquareFeet] <= 3000 need to evaluate to TRUE to return their respective "Small" and "Medium" values.
< $100 the sale is "Tiny"< $200 the sale is "Mid"Save the project and, from the course directory, submit the CLI tests.