Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Conditionally format bar chart based on another field value

Hi

 

Does anyone have a way to conditionally format bar chart columns based on another fields value?

 

I would like the colours to be Red and Green based on whether the sum is greater than a target value. 

 

The issue is the target values have changed over time and not static

 

Essentially i want to do;

 

If month value > target value = green

If month value < target value = red

 

I'm sure im missing an easy way to do this but i'm struggling!!

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @Anonymous 

 

Download example PBIX file

 

You need to create a measure that sets a color value based on the Target value, presumably this is a measure.

With that done, you can use the new color measure to set conditional formatting on the columns/bars

 

Measure to set color based on target value. I'm using Hex color codes, #0F0 is green, #F00 is red.

 

Column Color = IF(SUM('DataTable'[Value]) >= [Target], "#0F0", "#F00")

 

 

 

Then apply a CF rule

 

appcf.png

 

appcf2.png

 

appcf3.png

 

Regards

 

Phil

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

5 REPLIES 5
OneHotEncoder
Frequent Visitor

Hi all,

 

Thanks for the discussion and the answer to this topic.

I'm currently trying to do a conditional formatting for a similiar use-case.

I have two bars in a clustered column chart, first is the achieved number, 2nd bar is the target number.

I would like to add the following conditional formatting: if the achieved number is smaller than the target number, the achieved number bar should be red. Otherwise, the achieved target number bar will be green.

Both bars should be visible in the clustered column chart.

 

I setup the measure which does exactly this:

Achieved number Color = IF('Sheet1'[number_achieved] >= [Sheet1], "#0F0", "#F00")
 
The issue with your solution is that once I add the 2nd bar to the clustered column chart, it does not work anymore.
The conditonal formatting for the achieved bars vanish once adding the target bars..
 
Is there any solution to this?

Hi @OneHotEncoder 

 

If you can starrt a new topic and attach your PBIX file that'll make it easier to help you.

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Anonymous
Not applicable

Excellent, i new it would be a simple solution!

PhilipTreacy
Super User
Super User

Hi @Anonymous 

 

Download example PBIX file

 

You need to create a measure that sets a color value based on the Target value, presumably this is a measure.

With that done, you can use the new color measure to set conditional formatting on the columns/bars

 

Measure to set color based on target value. I'm using Hex color codes, #0F0 is green, #F00 is red.

 

Column Color = IF(SUM('DataTable'[Value]) >= [Target], "#0F0", "#F00")

 

 

 

Then apply a CF rule

 

appcf.png

 

appcf2.png

 

appcf3.png

 

Regards

 

Phil

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Seems this answer was issued for Power BI version 1.9 or so, an seems not to be available in version 2.130 anymore (or it has been moved into another place?) So far I wasn't able to find it.

FenixDigital_0-1728970522541.png

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.