In this Power BI tutorial, we will learn how to apply conditional formatting based on a Measure Percentage value in Power BI with various examples. In addition, we will also cover the below-mentioned topics:
- Power BI conditional formatting based on a measure bar chart
- Power BI conditional formatting based on the measure not working
- Power BI conditional formatting based on two measures
Power BI conditional formatting based on measure Percentage
Let us see how we can display the percent of the total value by measure in the Power Bi report,
In this example, we will use the financials data table, to display the COGS percentage of total value based on the Product 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.
- Use the below-mentioned formula to find the COGS percentage of total value based on the Product.
COGS Percentage =
Var Sumvalue = SUM(financials[COGS])
Var Category = CALCULATE ( SUM(financials[COGS]) , REMOVEFILTERS(financials[Product]))
return
Sumvalue/Category
Where,
- COGS Percentage = Measure Name
- financials = Table Name
- COGS, Product = Column Names
- Select the Power BI table visual from the visualization and drag-drop the created COGS Percentage measure value and product field from the field pane.
- To display the COGS percentage of total value based on the Product select the created measure Measure Tools -> Percentage as below:
- In the below screenshot, we can see that the table visually displays the COGS percentage value based on the Product category in the Power BI report.
- To apply conditional formatting, select the Format Visual under the Visualisation pane, and Expand Cell Elements under the Visual tab (highlighted in Red):
- Enable the background color and click on the Fx icon as shown below:
- Now, Select the Format style as Rules and choose the measure field value, Now add the rule that you want to apply. Select +New rule to add a new rule condition.
- Add the condition to apply the conditional formatting for the created measure value.
- Click on the Ok button to display the table visual based on the condition applied.
In the below screenshot, you can see that the displays the conditional formatting value for the created measure value is applied for the table visual.
This is how to display the percent of the total value by measure in the Power Bi report.
Also Read: Power BI Conditional Formatting Based on Text
Power BI conditional formatting based on a measure bar chart
Here we will see how we can apply conditional formatting based on a measure bar chart in Power BI.
In this example, we will display the created measure COGS Percentage value in the stacked bar chart in the Power BI report.
- Load source data into the Power Bi desktop. Selected the stacked bar chart visual drag and drop the Product field and the calculated COGS percentage measure value in the field section.
- To apply conditional formatting for bars, select the Format Visual under the Visualisation pane, and Expand Bars -> Colors under the Visual tab (highlighted in Red):
- Enable the background color and click on the Fx icon as shown below:
- Now, Select the Format style as Rules and choose the column field value, Now add the rule that you want to apply. Select +New rule to add a new rule condition.
- Add the condition to apply the conditional formatting for the created COGS Percentage measure value.
- Click on the Ok button to display the table visual based on the condition applied.
In the below screenshot, you can see that the displays the conditional formatting value for the created measure value is applied to the stacked bar chart in Power Bi.
This is how to apply conditional formatting based on a measure bar chart in Power BI.
Power BI conditional formatting based on the measure not working
- No, it is possible to apply conditional formatting based on the crated measure value presented in the field pane.
- In the conditional formatting pop-up window, based on Format by rules we can select the measure value field and apply the conditional formatting.
- In the following example, you can see how to work with conditional formatting based on the measures.
Power BI conditional formatting based on two measures
Let us see how we can apply conditional formatting based on two measures in the Power Bi report.
In the example, we will use the two measure values as COGS percentage value and Discount Percentage value in Power BI.
- Once the data has been loaded to the Power BI desktop, click on the new measure under the modeling tab.
- Use the below-mentioned formula to find the Discount percentage of the total value based on the Product.
Discount Percentage =
Var discountsum = SUM(financials[Discounts])
Var Category = CALCULATE ( SUM(financials[Discounts]) , REMOVEFILTERS(financials[Product]))
return
discountsum/Category
Where,
- Discount Percentage = Measure Name
- financials = Table Name
- Discounts, Product = Column Names
- Select the table visual, and drag-drop the created two measure values in it to display the values in percentage format select the created measure Measure Tools -> Percentage as below:
- In the below screenshot, we can see that the table visually displays the previously created COGS percentage value and discount percentage value based on the Product in the Power BI report.
- To apply conditional formatting for table cells, select Format Visual under the Visualisation pane.
- Expand Cell Elements and apply settings to the series called COGS Percentage measure value, enable the background color and click on the Fx icon as shown below:
- Now, Select the Format style as Rules and choose the measure field value, Now add the rule that you want to apply. Select +New rule to add a new rule condition.
- Add the condition to apply the conditional formatting for the created COGS Percentage measure value.
- Click on the Ok button to display the table visual based on the condition applied.
In the same way, select the applied setting to series as discount percentage measure value and apply conditional formatting.
- Now, Select the Format style as Rules and choose the measure field value, Now add the rule that you want to apply. Select +New rule to add a new rule condition.
- Add the condition to apply the conditional formatting for the created Discount Percentage measure value.
- Click on the Ok button to display the table visual based on the condition applied.
In the below screenshot, you can see that the displays the conditional formatting value for the created two measure values is applied for the table visual.
This is how to apply conditional formatting based on two measures in the Power BI Report.
In this Power BI tutorial, we have learned how to apply conditional formatting based on a measure percentage value in Power BI with various examples. In addition, we also covered the below-mentioned topics:
- Power BI conditional formatting based on a measure bar chart
- Power BI conditional formatting based on the measure not working
- Power BI conditional formatting based on two measures
You may also like the following Power BI tutorials:
- Get Current Month Sales Report using Power BI Measure
- difference between calculated column and measure in Power BI
- Power BI Measure Sum and Subtract Example
- How to sort slicer by measure in Power BI
- Power BI Measure If Text
- Power BI Bar Chart Conditional Formatting Multiple Values
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