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

Shape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.

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
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

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.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.