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

     <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


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(WEEKDAY(A2),1,”Sunday”,2,”Monday”,3,”Tuesday”,”No match”)

Related Course Modules