Power BI Switch Multiple Conditions

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.

Power BI switch Multiple Conditions
Power BI switch Multiple Conditions
  • 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,

  1. Available/NotAvailable = New Column Name
  2. SWITCH = Function Name
  3. Cars = Table Name
  4. 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.

Power BI Switch Multiple Values
Power BI Switch Multiple Values

This is how to filter the values based on the Switch function in Power BI.

See also  Power BI Merge Two Tables without Duplicates

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,

  1. Car Priorities = New Column Name
  2. SWITCH = Function Name
  3. Cars = Table Name
  4. Cost Price = Existing Column Names

The screenshot below displays the newly added column based on the condition applied.

Power BI switch true multiple conditions
Power BI switch true multiple conditions

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,

  1. Multiple criteria = New Column Name
  2. SWITCH = Function Name
  3. Cars = Table Name
  4. 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.

Power BI switch statement multiple criteria
Power BI switch statement multiple criteria

This is how to use a switch statement with multiple criteria using the switch function in Power Bi.

See also  How to add column with a fixed value 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,

  1. Multiple Conditions = New Column Name
  2. SWITCH = Function Name
  3. Cars = Table Name
  4. 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 functions in multiple conditions
Power BI switch functions in multiple conditions

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,

  1. Switch 2 conditions = New Column Name
  2. SWITCH = Function Name
  3. Cars = Table Name
  4. 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:
Power BI switch two conditions
Power BI switches two conditions

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:

Power BI switch two conditions example
Power BI switch two conditions example

This is how to use the two conditions using the switch functions in Power BI.

See also  How to Solve NaN Error 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,

  1. Car Price Ranges = New Column Name
  2. SWITCH = Function Name
  3. Cars = Table Name
  4. 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

Power BI switch between two values
Power BI switch between two values

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:

>