SWITCH Function (DAX)

How does the SWITCH function (DAX) work?

The SWITCH function (DAX) evaluates an expression against a list of values and returns one of multiple possible result expressions.

SWITCH Formula Syntax

SWITCH(
     <expression>, <value>, <result>[, <value>, <result>]…[, <else>]
)

How do you use the SWITCH function?

Use the SWITCH function to match a value of expression against several possibilities and return a result corresponding to the first matching value.

Related Blog Posts

Related Support Forum Posts

Slicer for switching analysis dimensions
Using A measure from a slicer as rule boundaries in a switch statement
Combine Calculate and Switch for multiple criteria or condition

Considerations when using the SWITCH function

The first argument is called “expression” and can be a hardcoded constant, a cell reference, or another formula that returns a specific value you want to match against. Matching values and results are entered in value/result pairs. SWITCH can handle up to 126 matches. A optional final argument specifies a default result to return in cases where there is no match.

Related Video Tutorials

Formula examples using the SWITCH function

=SWITCH([Month], 1, “January”, 2, “February”, 3, “March”, 4, “April” , 5, “May”, 6, “June”, 7, “July”, 8, “August” , 9, “September”, 10, “October”, 11, “November”, 12, “December” , “Unknown month number” )

=SWITCH(C5,1,”Poor”,2,”OK”,3,”Good”,”??”)

=SWITCH(WEEKDAY(A2),1,”Sunday”,2,”Monday”,3,”Tuesday”,”No match”)

Related Course Modules

Ultimate-Beginners-Guide-To-PowerBI
Center of Excellence

DOWNLOAD


Download our comprehensive DAX Formula Reference Guide as perfect companion as you learn how to use DAX formulas within Power BI.


Download DAX Formulas Reference Guide
Download DAX Formula Reference Guide
Membership