Evaluates an expression against a list of values and returns one of multiple possible result expressions. It comes under Logical Dax function category.
Syntax:
SWITCH(<expression>, <value>, <result>[, <value>, <result>]…[, <else>])
Description:
S 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 | Any scalar expression to be evaluated if the result of expression doesn’t match any of the value arguments. |
Note:
All result expressions and the else expression must be of the same data type.
So, Let’s start with an example, you can download the sample Dataset from below link
Step-1: Create one measure and write conditional statement as mentioned below.
Sales_Tag = Var TotalSales= SUM(Orders[Sales]) Return SWITCH(TRUE(), TotalSales<50000, "Low", TotalSales>50000 && TotalSales< 100000, "Medium", TotalSales>100000, "High", "Other" )
Step-2: If condition has true, Switch will return the result in form of “Low”, “Medium” & “High”.

Switch DAX Output 1
Step-3: You can change the font color white for Sales_Tag measure total, because here no need to display Text as in Total. Due to this.
Select table visual > format bar > field Formatting, and follow the below properties:
- Select Sales_Tag from dropdown
- Choose font color white, by default it is selected but select again to apply this.
- Turned off Apply to values
- Turned on Apply to total

Table Formatting
Get Month Name from Month number:
Create one calculated column, and write below SWICTH DAX formlua to get month name from month number.
Return Month Name = SWITCH(Orders[MonthNumber], 1,"January", 2,"February", 3,"March", 4,"April", 5,"May", 6,"June", 7,"July", 8,"August", 9,"September", 10,"October", 11,"November", 12,"December", "Invalid Month Number" )

Switch DAX output 2
Hope you enjoyed the post. Your valuable feedback, question, or comments about this post are always welcome or you can leave us message on our contact form , we will revert to you asap.