SWITCH() Function is a power bi dax logical function which evaluates an expression against a list of values and returns different results depending on the value of an expression.

It returns a scalar value of any type.

Scalar value that either coming from one of the result expression it is matched with value or from else expression if it is not matched with any value.


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

<expression> is an expression that is to be evaluated,returns scalar value.

<value> is constant value that is to be matched with the results of an expression.

<result> is the result to be returned if expression has corresponding value.

<else> If there are no matching values the Else value is returned. It is an optional. Else expression must have same data type as result expression.

Lets go through an example to see SWITCH() Function in action.

As you can see, here we have a slicer which contains number lists from 1 to 10 and a table visual which displays number list.

Now we have to display a name of number against each number in table visual means if number is 1 then it will be “one”, if 2 then “two” and so on..

For this we will create a DAX using switch function which evaluates an expression against a list of numbers and returns different results.

GetNumberInWord =

VAR SelectedNum =

SELECTEDVALUE ( NumberList[Number] )




1, "ONE",

2, "TWO",

3, "THREE",

4, "FOUR",

5, "FIVE",

6, "SIX",

7, "SEVEN",

8, "EIGHT",

9, "NINE",

10, "TEN",



Once you commit the dax, a GetNumberInWord  measure is created, now  drag the measure into table visual next to Number field.
As you can see for selected numbers in slicers, there is a name for each number those are selected in slicer.
Also Read..

SQL Basics TutorialSQL Advance TutorialSSRSInterview Q & A
SQL Create tableSQL Server Stored ProcedureCreate a New SSRS Project List Of SQL Server basics to Advance Level Interview Q & A
SQL ALTER TABLESQL Server MergeCreate a Shared Data Source in SSRSSQL Server Question & Answer Quiz
SQL DropSQL Server PivotCreate a SSRS Tabular Report / Detail Report
..... More.... More....More
Power BI TutorialAzure TutorialPython TutorialSQL Server Tips & Tricks
Download and Install Power BI DesktopCreate an Azure storage accountLearn Python & ML Step by stepEnable Dark theme in SQL Server Management studio
Connect Power BI to SQL ServerUpload files to Azure storage containerSQL Server Template Explorer
Create Report ToolTip Pages in Power BICreate Azure SQL Database ServerDisplaying line numbers in Query Editor Window

 876 total views,  1 views today

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.