Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.
Hi!
I would like to know, how can I change this DAX Code ... to use Switch Case instead of IFs
Solved! Go to Solution.
@AGaribay7 Try
SEASON TOTAL =
SWITCH(
TRUE(),
VALUES(Rankings[Attribute]) = "AERIAL DUELS WON %", FORMAT(SUM(Rankings[Value]),"##%"),
VALUES(Rankings[Attribute]) = "CROSSES", FORMAT(SUM(Rankings[Value]),"##"),
VALUES(Rankings[Attribute]) = "Crossing%", FORMAT(SUM(Rankings[Value]),"##%"),
VALUES(Rankings[Attribute]) = "FORWARD PASSES %", FORMAT(SUM(Rankings[Value]),"##%"),
VALUES(Rankings[Attribute]) = "FOULS COMMITTED", FORMAT(SUM(Rankings[Value]),"##"),
VALUES(Rankings[Attribute]) = "GOALS", FORMAT(SUM(Rankings[Value]),"##"),
VALUES(Rankings[Attribute]) = "GOALS CONCEDED", FORMAT(SUM(Rankings[Value]),"##"),
VALUES(Rankings[Attribute]) = "GROUND DUELS WON %", FORMAT(SUM(Rankings[Value]),"##%"),
VALUES(Rankings[Attribute]) = "NON-PENALTY SHOT CONVERSION RATE %", FORMAT(SUM(Rankings[Value]),"##%"),
VALUES(Rankings[Attribute]) = "NON-PENALTY SHOTS", FORMAT(SUM(Rankings[Value]),"##"),
VALUES(Rankings[Attribute]) = "OWN HALF BALL LOSS", FORMAT(SUM(Rankings[Value]),"##"),
VALUES(Rankings[Attribute]) = "PASS FORWARD IN FINAL 3RD %", FORMAT(SUM(Rankings[Value]),"##%"),
VALUES(Rankings[Attribute]) = "PASSES", FORMAT(SUM(Rankings[Value]),"##"),
VALUES(Rankings[Attribute]) = "POSSESSION REGAINS IN OPPO HALF TOTAL", FORMAT(SUM(Rankings[Value]),"##"),
VALUES(Rankings[Attribute]) = "Possession%", FORMAT(SUM(Rankings[Value]),"##%"),
VALUES(Rankings[Attribute]) = "RED CARDS", IF(SUM(Rankings[Value]) > 0, FORMAT(SUM(Rankings[Value]),"##"), 0),
VALUES(Rankings[Attribute]) = "SHOTS INSIDE BOX", FORMAT(SUM(Rankings[Value]),"##"),
VALUES(Rankings[Attribute]) = "SHOTS ON TARGET %", FORMAT(SUM(Rankings[Value]),"##%"),
VALUES(Rankings[Attribute]) = "SHOTS OUTSIDE BOX", FORMAT(SUM(Rankings[Value]),"##"),
VALUES(Rankings[Attribute]) = "Successful Box Cross", FORMAT(SUM(Rankings[Value]),"##"),
VALUES(Rankings[Attribute]) = "YELLOW CARDS", FORMAT(SUM(Rankings[Value]),"##"),
BLANK() -- Default case if no condition matches
)
💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn
@AGaribay7 Try
SEASON TOTAL =
SWITCH(
TRUE(),
VALUES(Rankings[Attribute]) = "AERIAL DUELS WON %", FORMAT(SUM(Rankings[Value]),"##%"),
VALUES(Rankings[Attribute]) = "CROSSES", FORMAT(SUM(Rankings[Value]),"##"),
VALUES(Rankings[Attribute]) = "Crossing%", FORMAT(SUM(Rankings[Value]),"##%"),
VALUES(Rankings[Attribute]) = "FORWARD PASSES %", FORMAT(SUM(Rankings[Value]),"##%"),
VALUES(Rankings[Attribute]) = "FOULS COMMITTED", FORMAT(SUM(Rankings[Value]),"##"),
VALUES(Rankings[Attribute]) = "GOALS", FORMAT(SUM(Rankings[Value]),"##"),
VALUES(Rankings[Attribute]) = "GOALS CONCEDED", FORMAT(SUM(Rankings[Value]),"##"),
VALUES(Rankings[Attribute]) = "GROUND DUELS WON %", FORMAT(SUM(Rankings[Value]),"##%"),
VALUES(Rankings[Attribute]) = "NON-PENALTY SHOT CONVERSION RATE %", FORMAT(SUM(Rankings[Value]),"##%"),
VALUES(Rankings[Attribute]) = "NON-PENALTY SHOTS", FORMAT(SUM(Rankings[Value]),"##"),
VALUES(Rankings[Attribute]) = "OWN HALF BALL LOSS", FORMAT(SUM(Rankings[Value]),"##"),
VALUES(Rankings[Attribute]) = "PASS FORWARD IN FINAL 3RD %", FORMAT(SUM(Rankings[Value]),"##%"),
VALUES(Rankings[Attribute]) = "PASSES", FORMAT(SUM(Rankings[Value]),"##"),
VALUES(Rankings[Attribute]) = "POSSESSION REGAINS IN OPPO HALF TOTAL", FORMAT(SUM(Rankings[Value]),"##"),
VALUES(Rankings[Attribute]) = "Possession%", FORMAT(SUM(Rankings[Value]),"##%"),
VALUES(Rankings[Attribute]) = "RED CARDS", IF(SUM(Rankings[Value]) > 0, FORMAT(SUM(Rankings[Value]),"##"), 0),
VALUES(Rankings[Attribute]) = "SHOTS INSIDE BOX", FORMAT(SUM(Rankings[Value]),"##"),
VALUES(Rankings[Attribute]) = "SHOTS ON TARGET %", FORMAT(SUM(Rankings[Value]),"##%"),
VALUES(Rankings[Attribute]) = "SHOTS OUTSIDE BOX", FORMAT(SUM(Rankings[Value]),"##"),
VALUES(Rankings[Attribute]) = "Successful Box Cross", FORMAT(SUM(Rankings[Value]),"##"),
VALUES(Rankings[Attribute]) = "YELLOW CARDS", FORMAT(SUM(Rankings[Value]),"##"),
BLANK() -- Default case if no condition matches
)
💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn
Hi,
Try the following code:
Note: this will only make the code prettier, there is no performance benefit.
SEASON TOTAL = SWITCH(TRUE(),
VALUES(Rankings[Attribute]) in {
"AERIAL DUELS WON %",
"Crossing%",
"FORWARD PASSES %",
"GROUND DUELS WON %",
"NON-PENALTY SHOT CONVERSION RATE %",
"Possession%",
"SHOTS ON TARGET %"}, format(SUM(Rankings[Value]),"##%"),
format(SUM(Rankings[Value]),"##")
)
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 8 | |
| 6 | |
| 3 | |
| 3 | |
| 3 |
| User | Count |
|---|---|
| 11 | |
| 9 | |
| 8 | |
| 7 | |
| 6 |