In this Power Bi tutorial, we will learn a few examples of Power BI Switch Multiple Conditions. Also, we will cover the below topics:
- Power BI Switch Multiple Conditions
- Power BI switch true multiple conditions
- Power BI switch statement multiple criteria
- Power BI switch functions in multiple conditions
- Power Bi switch 2 conditions
- Power BI switch between two values
Power BI Switch
The Power BI switch function considers an expression against a list of values and returns one of the multiple possible result expressions.
The Power BI Switch syntax is:
=SWITCH (<expression>, <value>, <result>[,<value>, <result>]...[,<else>])
In the following, we will see an example of how to use the switch function works:
Power BI Switch Multiple Values
Let us see how we can filter the values using the Power BI Switch function in Power BI.
In this example, we will use the below-mentioned Vehicles excel sheet as a data source, and we will filter the cars based on the conditions using the switch function in Power BI.
- Initially, log in to the Power BI desktop and load data into it. Once the data has been loaded Select the data view from the report page.
- Select Tables tools -> New Column option and use the below formula and click on the check icon.
Available/NotAvailable = SWITCH (
TRUE (),
Cars[Car Names] = "Ford" && Cars[Color] = "Red", "Red Ford Available",
Cars[Car Names] = "Benz" && Cars[Color] = "Black", " Black Benz Available "
)
Where,
- Available/NotAvailable = New Column Name
- SWITCH = Function Name
- Cars = Table Name
- Car Names, Color = Existing Column Names
In the below screenshot, you can see that the new column has been added to the existing table and displays the result as available or not available based on the applied condition.
This is how to filter the values based on the Switch function in Power BI.
Power BI Switch true multiple conditions
Here we will see how to use switch true multiple conditions in Power Bi.
Power BI DAX Switch, a true is an expression that performs like a nested IF statement, which checks row by row in the formula. It returns a result when our calculation is true according to the expression.
In this example, we will filter the car value based on the cost price using the switch function in Power Bi.
Car Priorities = SWITCH(
TRUE(),
Cars[Cost Price]<=100000,"good",
Cars[Cost Price]<400000, "Better",
Cars[Cost Price]<=600000,"Best",
"Execellent"
)
Where,
- Car Priorities = New Column Name
- SWITCH = Function Name
- Cars = Table Name
- Cost Price = Existing Column Names
The screenshot below displays the newly added column based on the condition applied.
This is how to use switch true multiple conditions in Power Bi.
Also check, Power BI IF NULL then 0
Power BI switch statement multiple criteria
Here we will see how to use a switch statement with multiple criteria using the switch function in Power Bi.
In this example, we will find the available cars based on the car price and car color using the Power Bi switch function in Power BI.
- Load data to the Power Bi desktop and select the data view.
- Select the New Column option and under the table tools use the below formula:
Multiple criteria = SWITCH(TRUE(),
Cars[Car Names]="Honda" && Cars[Cost Price]>= 1000000,"Available",
Cars[Car Names]="Ford" &&Cars[Color]="Silver","Available",
"Temporarily Not Available"
)
Where,
- Multiple criteria = New Column Name
- SWITCH = Function Name
- Cars = Table Name
- Car Names, Cost Price, Color = Existing Column Names
The Screenshot below displays the result value in the newly added column based on the condition applied.
This is how to use a switch statement with multiple criteria using the switch function in Power Bi.
Power BI switch functions in multiple conditions
Let us see how we can filter the values with multiple conditions using the switch function in Power Bi.
In this example, we will use the AND function and OR function to filter the values based on multiple conditions.
- Open and Load data to the Power Bi desktop and select the data view.
- Choose the New Column option and under table tools and use the below formula:
Multiple Conditions =
SWITCH (
TRUE (),
Cars[Car Names] <> BLANK ()
&& Cars[Car Model] = "Q7", "Temporarily not available",
[Car Names]="Ford"&&[Car Model]="Model A" ||
[Car Names]="Hyndai"&&[Car Model]="Creata S" ||
[Car Names]="Honda"&&[Car Model]="Honda WR-V","Available",
"not available"
)
Where,
- Multiple Conditions = New Column Name
- SWITCH = Function Name
- Cars = Table Name
- Car Names, Cost Price, Car Model, Color = Existing Column Names
In the below screenshot, you can see that the newly added column displays the result based on the multiple conditions applied.
Power BI switch 2 conditions
Here we will see how to use the two conditions using the switch functions in Power BI.
In this example, we will see how to find the minimum price and maximum price of the car based on the car type using the switch function in Power Bi.
- Load data to the Power Bi desktop and click on the data view. Then select the Table tools -> New Column option and apply the below-mentioned formula:
Switch 2 conditions =
IF (
Cars[Car Names]= "Ford",
SWITCH (
TRUE (),
Cars[Cost Price]>=700000, "Maximum Price",
Cars[Cost Price] <=600000, "Minimum Price"),BLANK()
)
Where,
- Switch 2 conditions = New Column Name
- SWITCH = Function Name
- Cars = Table Name
- Car Names, Cost Price = Existing Column Names
- The screenshot below displays the minimum price and maximum price for the selected car type using the switch function.
- Here I have selected the car type as ford to filter the minimum and maximum prices for the selected car as below:
In the same way, we can change the car type to Honda to check the minimum and maximum price value for the selected car as below:
This is how to use the two conditions using the switch functions in Power BI.
Check out, Power BI Measure If Multiple Conditions
Power BI switch between two values
Let us see how we can filter between two values using the switch function in Power BI,
In this example, we will filter the two between values based on the Car price ranges using the switch function in Power BI.
- Open and Load data into the Power Bi desktop and select the data view.
- Choose the New Column option and under table tools and use the below-mentioned formula:
Car Price Ranges = SWITCH(
TRUE(),
Cars[Cost Price]<=600000,"0-600000",
Cars[Cost Price]<=1000000,"600000-1000000","1000000-6000000"
)
Where,
- Car Price Ranges = New Column Name
- SWITCH = Function Name
- Cars = Table Name
- Cost Price = Existing Column Names
In the below screenshot, you can see that the newly added column displays the car price ranges between two values in Power Bi
This is how to filter between two values using the switch function in Power BI.
In this Power Bi tutorial, we have learned what is Power Bi Switch function and how to work with Power BI switch multiple values with various examples. Also, we covered the below topics:
- Power BI switch true multiple conditions
- Power BI switch statement multiple criteria
- Power BI switch functions in multiple conditions
- Power Bi switch 2 conditions
- Power BI switch between two values
You may also like the following Power BI tutorials:
- Power BI Month over Month Change
- Object Level Security (OLS) in Power BI
- How to implement row level security (RLS) in Power BI
- Calculate Percentage of Rows in Power BI
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com