IF and SWITCH are decision-making functions in DAX. They help convert raw numbers into meaningful business labels such as Pass/Fail, Grade, Status, or Category.
// Basic IF syntax
IF(Condition,Result_if_True,Result_if_False)
// SWITCH with TRUE for range conditions
SWITCH(
TRUE(),
Condition1,Result1,
Condition2,Result2,
DefaultResult
)
| ID | Name | Marks |
|---|---|---|
| 1 | Aditi | 92 |
| 2 | Rahul | 76 |
| 3 | Neha | 61 |
| 4 | Aman | 35 |
Business Question: Has the student passed?
Rule: Marks ≥ 40 → Pass else Fail
// Pass or Fail decision for each student
Result =
IF(Students[Marks] >= 40,"Pass","Fail")
Business Question: Who gets scholarship?
Rule: Marks ≥ 80 → Eligible else Not Eligible
// Scholarship eligibility logic
Scholarship =
IF(Students[Marks] >= 80,"Eligible","Not Eligible")
// Grade assignment using SWITCH
Grade =
SWITCH(
TRUE(),
Students[Marks] >= 90,"A",
Students[Marks] >= 75,"B",
Students[Marks] >= 60,"C",
"D"
)
Enter a numeric value below to see how all three DAX functions would process it simultaneously.