Forum Discussion
Conditional formatting for category axis labels based on Budget vs Actual
Hi everyone,
I’m working on a clustered bar chart in Power BI and would like to apply conditional formatting to the category (Y-axis) labels based on a comparison between Budget and Actual values.
Requirement:
For each category:
- If Budget > Actual → category label should be green
- If Budget < Actual → category label should be red
Details:
- Visual: Clustered Bar Chart
- Y-axis: Category dimension
- Values: Budget and Actual measures
Problem:
I know how to apply conditional formatting to data colors (bars), but I’m unable to find a way to dynamically change the color of the category labels based on a measure condition.
Ask:
Is it possible in Power BI to conditionally format axis/category labels based on measure logic?
If yes, how can it be achieved? If not, are there any workarounds?
Thanks in advance!
Hi mahendrakanouji - No, this is not natively supported in Power BI's clustered bar chart.
Ref: Create and use column charts in Power BI - Power BI | Microsoft Learn
Suggest: Color the bars instead apply conditional formatting to the bar data colors using a DAX measure like: eg: Bar Color =
IF([Budget] > [Actual], "green", "red")or try with Deneb custom visual (advanced)
Hope this helps.
Hi mahendrakanouji,
Just want to let you know that category label conditional formatting is not supported as of now. You can use the bar chart with colur formatting (stacked bar is supported) not the clustered column chart.
You can create the measure likeBar Color =SWITCH(TRUE(),[Budget Total] > [Actual Total], "#2E7D32", -- green[Budget Total] < [Actual Total], "#C62828", -- red"#9E9E9E" -- default/else (equal or blank))
Use the bar chart colur formatting byplease consider as an accepted solution or give some kudos.
https://community.fabric.microsoft.com/t5/Desktop/Bar-chart-conditional-Y-Axis-Label-color-based-on-value-measure/td-p/2412331
https://community.fabric.microsoft.com/t5/Desktop/Conditional-Formatting-Y-axis-categories/td-p/2208667
You can upvote for the same feature availability in the future release
https://community.fabric.microsoft.com/t5/Fabric-Ideas/Conditional-formatting-of-a-category/idi-p/4525469
5 Replies
- rajendraongole1
Super User
Hi mahendrakanouji - No, this is not natively supported in Power BI's clustered bar chart.
Ref: Create and use column charts in Power BI - Power BI | Microsoft Learn
Suggest: Color the bars instead apply conditional formatting to the bar data colors using a DAX measure like: eg: Bar Color =
IF([Budget] > [Actual], "green", "red")or try with Deneb custom visual (advanced)
Hope this helps.
- Lodha_Jaydeep
Solution Sage
Hi mahendrakanouji,
Just want to let you know that category label conditional formatting is not supported as of now. You can use the bar chart with colur formatting (stacked bar is supported) not the clustered column chart.
You can create the measure likeBar Color =SWITCH(TRUE(),[Budget Total] > [Actual Total], "#2E7D32", -- green[Budget Total] < [Actual Total], "#C62828", -- red"#9E9E9E" -- default/else (equal or blank))
Use the bar chart colur formatting byplease consider as an accepted solution or give some kudos.
https://community.fabric.microsoft.com/t5/Desktop/Bar-chart-conditional-Y-Axis-Label-color-based-on-value-measure/td-p/2412331
https://community.fabric.microsoft.com/t5/Desktop/Conditional-Formatting-Y-axis-categories/td-p/2208667
You can upvote for the same feature availability in the future release
https://community.fabric.microsoft.com/t5/Fabric-Ideas/Conditional-formatting-of-a-category/idi-p/4525469 - oussamahaimoud
Memorable Member
Hi mahendrakanouji,
Create a color measure:
Category Color =
IF(
[Budget] > [Actual],
"green",
IF(
[Budget] < [Actual],
"red",
"black"
)
)
Build a Matrix visual
- Rows: your Category dimension
- Values: Budget, Actual
- Apply conditional formatting on the Category column background or font color using your Category Color measure → Format by field value
Then place this Matrix directly to the left of your clustered bar chart, align row heights, remove borders, and hide the matrix headers. Visually it mimics a colored Y-axis label.
- v-hashadapu
Community Support
Hi mahendrakanouji , Thank you for reaching out to the Microsoft Community Forum.
We find the answers shared by Lodha_Jaydeep , rajendraongole1 & oussamahaimoud are correct for your issue. Can you please confirm if the solution worked for you. It will help others with similar issues find the answer easily.
Thank you rajendraongole1 , Lodha_Jaydeep & oussamahaimoud for your valuable responses.
- v-hashadapu
Community Support
Hi mahendrakanouji , Hope you're doing fine. Can you confirm if the problem is solved or still persists? Sharing your details will help others in the community.