DAX Function Guide

SWITCH
Empty image or helper icon

Sam McKay

CEO & Founder

How does the SWITCH 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?

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

Loading

Considerations when using the SWITCH?

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

Loading

Formula examples using the SWITCH

=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 Courses

Loading