Export (0) Print
Expand All
8 out of 9 rated this helpful - Rate this topic

SWITCH Function (DAX)

SQL Server 2012

Evaluates an expression against a list of values and returns one of multiple possible result expressions.

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

Any DAX expression that returns a single scalar value, where the expression is to be evaluated multiple times (for each row/context).


A constant value to be matched with the results of expression.


Any scalar expression to be evaluated if the results of expression match the corresponding value.


Any scalar expression to be evaluated if the result of expression doesn't match any of the value arguments.

A scalar value coming from one of the result expressions, if there was a match with value, or from the else expression, if there was no match with any value.

All result expressions and the else expression must be of the same data type.

The following example creates a calculated column of month names.

=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" )

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft. All rights reserved.