
- DAX Functions Tutorial
- DAX Functions - Home
- DAX Functions - Introduction
- DAX Parameter Naming Conventions
- Description Structure
- DAX Functions - Aggregation
- DAX Functions - Filter
- DAX Functions - Time Intelligence
- DAX Functions - Date and Time
- DAX Functions - Information
- DAX Functions - Logical
- Math & Trigonometric Functions
- DAX Functions - Parent & Child
- DAX Functions - Statistical
- DAX Functions - Text
- DAX Functions - Other
- DAX Functions Useful Resources
- DAX Functions - Quick Guide
- DAX Functions - Useful Resources
- DAX Functions - Discussion
DAX Logical - SWITCH function
Description
Evaluates an expression against a list of values and returns one of multiple possible result expressions.
Syntax
SWITCH ( <expression>, <value>, <result>, [<value>, <result>] …, [<else>] )
Parameters
Sr.No. | Parameter & Description |
---|---|
1 |
expression Any DAX expression that returns a single scalar value, where the expression is to be evaluated multiple times for each row/context. |
2 |
value A constant value to be matched with the results of expression. |
3 |
result Any scalar expression to be evaluated, if the results of expression match the corresponding value. |
4 |
else Optional. Any scalar expression to be evaluated, if the result of expression doesn't match any of the value arguments. |
Return Value
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.
Remarks
All the result expressions and the else expression must be of the same data type.
Example
= SWITCH ( [Week Day], 1, "Sunday", 2, "Monday", 3, "Tuesday", 4, "Wednesday", 5, "Thursday", 6, "Friday", 7, "Saturday", "Unknown" )
This DAX formula returns a calculated column with the names of the Week Day values.