Power BI Measure If Multiple Conditions

In this Power BI tutorial, we will learn how to work with Measure If Multiple Conditions in Power BI, and also we will see how we can achieve the Measure Count If Multiple Conditions with various examples in Power BI.

Moreover, we will also cover the below topics:

  • Power BI DAX Measure If Multiple Conditions
  • Power BI Count Multiple Conditions
  • Calculate Power BI Multiple Conditions
  • Power BI IF statement with 3 conditions
  • Multiple if statements in the Power Bi custom column

Power BI Measure If Multiple Conditions

Let us see how we can display the values of multiple conditions using the Power BI Measure Power BI.

In this example, we will use the Stocks table data as a data source and filter values using the multiple if conditions with different values in Power BI.

  • Log in to the Power Bi desktop and load data using the get data option. Once the data has been loaded, select the new measure option and use the below formula:
Multiple Conditions Measure = IF(
     SELECTEDVALUE(Stocks[Stock Name]) = "Apple"&& SELECTEDVALUE(Stocks[Symbol]) = "AAPL",
      "Apple",
      IF(
         SELECTEDVALUE(Stocks[Stock Name]) = "Facebook"&& SELECTEDVALUE(Stocks[Symbol]) = "FB"&& SELECTEDVALUE(Stocks[Shares]) =50,
         "Facebook",
         BLANK ()
         )
      )

Where,

  1. Multiple Conditions Measure = New Measure
  2. Stocks = Table Name
  3. Stock Name = Column Name
  4. SELECTEDVALUE & BLANK = Function Name

Select the table visual from the visualization, drop the Stock name, Symbol, shares, and the created measure value into the columns section as shown below:

Power BI Measure If Multiple Conditions
Power BI Measure If Multiple Conditions

In the below screenshot, you can see that the measure returns values based on the multiple conditions applied else, it returns a blank value.

Power BI Measure If Multiple Conditions example
Power BI Measure If Multiple Conditions Example

This is how to display the values of multiple conditions using the Power BI Measure Power BI.

Power BI Measure Count If Multiple Conditions

Here we will see how we can count the values using Power BI If a function with multiple conditions in Power BI.

Load the data into the Power Bi desktop and click on the new measure and apply the below-mentioned formula:

Result = 
VAR item_count1 = 
COUNTAX(FILTER('Stocks','Stocks'[Stock Name] = "Amazon"),Stocks[Shares])
VAR item_count2 =
CALCULATE(
    COUNTAX( FILTER('Stocks','Stocks'[Stock Name] = "Microsoft"),Stocks[Shares])
   )

RETURN IF(
    item_count1 >= 1 || item_count2 >=1,
    "OK", 
    "NOT OK"
)

Where,

  1. Result = New Measure name
  2. item_count1 , item_count2 = Variable Names
  3. Stocks = Table Name
  4. Stock Name = Column Name
  5. COUNTAX = Function Name

From the visualization choose the table visual, drag-drop the Stock name, Symbol, shares, and the created measure value into the columns section as shown below:

Example of Power BI Measure If Multiple Conditions
Example of Power BI Measure If Multiple Conditions
  • The screenshot below displays the result value based on the applied condition in Power BI.
  • If the Stock name matches with the mentioned name and the county is greater than or equal to 1 it returns the value as OK else it returns NOT OK as below:
Power BI Measure Count If Multiple Conditions
Power BI Measure Count If Multiple Conditions

This is how to count the values using Power BI If a function with multiple conditions in Power BI.

Power BI DAX Measure If Multiple Conditions

Here we will see how we will use the Power BI Dax function to calculate values with multiple conditions in Power BI.

In this example, we will find the value if the value stock shares value matches with the stock name then it returns a true value else it returns a false value.

Open and Load data using the get data option into the Power Bi desktop. Click on the new column option under the modeling tab and apply the below-mentioned formula:

Multiple Conditions = 
IF(
   AND(
       Stocks[Stock Name] = "Intel",
       'Stocks'[Shares] = 200 || 'Stocks'[Shares] = 185 || Stocks[Shares] = 50
      ),
   "True", "False"
  )

where,

  1. Multiple Conditions = New Calculated column
  2. AND = Function Name
  3. Stocks = Table Name
  4. Shares = Existing Column Name

In the below screenshot, you can see that the newly added column displays the result as true when the stock shares values match with the stock name value Else, it displays the false value.

Power BI DAX Measure If Multiple Conditions
Power BI DAX Measure If Multiple Conditions

This is how to use the Power BI Dax function to calculate values with multiple conditions in Power BI.

Read Power BI Slicer Multiple Selection

Power BI Count Multiple Conditions

Let us see how to count the values using the Power BI Count function with Multiple conditions in Power BI.

In this example, we will use the table visual and the card’s visual to check the count value based on the condition applied in Power BI.

Load data to the Power Bi desktop using the get data option, click on the new measure option under the modeling tab, and use the below formula.

Total Count = COUNTX(
    FILTER(
        Stocks,
        Stocks[Stock Name] = "SalesForce"
            && Stocks[Product Status] = "Delivered"
    ),
Stocks[Stock Name]
)

where,

  1. Total Count = New measure name
  2. FILTER = Function Name
  3. Stocks = Table Name
  4. Stock Name, Product Status = Existing Column Names
  • Add the table visual and card visual from the visualizations to the Power BI report canvas.
  • In the table visually drag-drop the Stock name, Symbol, shares, and product status value into the columns section, and in the card visually drag and drop the created measure value to display the count as below:
Power BI Count Multiple Conditions
Power BI Count Multiple Conditions

In the same way, it displays the count value based on the multiple conditions applied. In the below screenshot, you can see that I have changed the data value so the card visually displays the count value as 2.

Power BI Count Multiple Conditions example
Power BI Count Multiple Conditions Example

This is how to count the values using the Power BI Count function Multiple conditions in Power BI.

Calculate Power BI Multiple Conditions

Here we will see how to calculate values using the Power Bi calculate function with multiple conditions in Power BI.

In this example, we will create two measure values to calculate the value of total shares and sale value in Power BI.

  • Log in to the Power Bi desktop and use the get data option to load data, once the data has been loaded click on the new measure under the modeling tab and use the below formula to find the value of the total shares.
Total Shares = SUM(Stocks[Shares]) 

Where,

  1. Total Shares = Measure Name
  2. Stocks = Table Name
  3. Shares = Column Name

In the same way, click on another new measure and use the below formula to calculate the sale value based on the different stock names.

Sale value  = CALCULATE(Stocks[Total Shares],Stocks[Stock Name]="Amazon" || Stocks[Stock Name]="Cisco")

Where,

  1. Sale value = Measure Name
  2. Total Shares = Existing measure
  3. Stocks= Table Name
  4. Stock Name = Column Name
  • From the visualization, select the table visual and card visual and add them to the Power BI report canvas.
  • In the table visually drag-drop the Stock name, Symbol, and shares into the columns section, and in the card visually drag and drop the created measure value to display the sale value based on the condition applied:
Calculate Power BI Multiple Conditions
Calculate Power BI Multiple Conditions

In the below screenshot, you can see that the measure returns a sale value in card visuals based on the multiple conditions applied.

Calculate Power BI Multiple Conditions example
Calculate Power BI Multiple Conditions Example

This is how to calculate values using Power Bi calculate function with multiple conditions in Power BI.

Read How to Concatenate with Space in Power BI

Power BI IF statement with 3 conditions

Let us see how we can filter value using the Power BI IF statement with 3 conditions in Power BI.

In this example, we will use an if statement with three conditions, if the value matches then it returns the true value else it displays the false value.

Load data into the Power Bi desktop, select a new column under the modeling tab, and use the below-mentioned formula.

IF 3 conditions = IF(Stocks[Stock Name] = "Amazon" && Stocks[Shares] = "185" && Stocks[Product Status]="Delivered", "True","False")

Where,

  1. IF 3 conditions = New Calculated column
  2. Stocks = Table Name
  3. Shares, Product Status, Stock Name = Existing Column Names

In the below screenshot, you can see that the newly added column displays the result as true when the stock shares values match with the stock name and product status value Else, it displays the false value.

Power BI IF statement with 3 conditions
Power BI IF statement with 3 conditions

This is how to filter value using the Power BI IF statement with 3 conditions in Power BI.

Multiple if statements in the Power Bi custom column

Here we will see how we can filter the value using multiple if statements in the Power Bi custom column in Power BI.

In this example, we will add a new custom column with multiple if statements, if the value matches based on the applied condition it displays a true value else it returns a false value.

Load data into the Power Bi desktop, select modeling -> new column then apply the below-mentioned formula.

Multiple if statements = IF (
    OR (
        AND ( Stocks[Stock Name]= "Cisco", Stocks[Product Status] = "Pending" ),
        AND ( Stocks[Stock Name] = "Facebook", Stocks[Product Status]= "Shipped" )
    ),
    TRUE (),
    FALSE()
)

Where,

  1. IF 3 conditions = New Calculated column
  2. Stocks = Table Name
  3. Shares, Product Status, Stock Name = Existing Column Names

In the below screenshot, you can see that the newly added column displays the result as true based on the multiple if conditions. Else, it returns the false value.

Multiple if statements in the Power Bi custom column
Multiple if statements in the Power Bi custom column

This is how to filter the value using multiple if statements in the Power Bi custom column in Power BI.

In this Power BI tutorial, we have learned how to work with Measure If Multiple Conditions in Power BI, and we also saw how we can achieve the Measure Count If Multiple Conditions with various examples in Power BI.

Moreover, we also covered the below topics:

  • Power BI DAX Measure If Multiple Conditions
  • Power BI Count Multiple Conditions
  • Calculate Power BI Multiple Conditions
  • Power BI IF statement with 3 conditions
  • Multiple if statements in the Power Bi custom column

You may also like the following Power BI tutorials:

>