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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
CLCastroEn
Helper IV
Helper IV

How to change color bars as you pass a target ?

Hello everyone!

I need your help with a problem I have. What happens is that I need the bar to change color to green if it passes a target or constant value, or to change to red if it doesn't already arrive. attached photo of my graph

the idea is that after the intermittent line that comes out on the x-axis, it is the color change.

I'd be very grateful if you could help me.

1 ACCEPTED SOLUTION
pranit828
Community Champion
Community Champion

Hi @CLCastroEn 

 

I would use conditional formatting in this case with % TR values as a percentage above the limit.

 

Did I resolve your issue? Mark my post as a solution! Appreciate your Kudos, Press the thumbs up button!!

 

Regards,
Pranit





PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile

View solution in original post

8 REPLIES 8
DataZoe
Employee
Employee

@CLCastroEn You could try this approach, which builds on a solution I did earlier.

 

Add a measure for each color you want:

 

[Measure Red] = if([Measure]<100,[Measure],blank())

[Measure Green] = if([Measure]>=100,[Measure],blank())

 

Now you put both of those measures in your bar chart, and then choose what color you want like you want each to be:

 

donutColors.JPG

 

I hvae a PBIX here, and while you don't need the whole solution, you can use the measures for each color idea for your question: https://github.com/DataZoe/PBIX/blob/master/DonutShape.pbix 

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

amitchandak
Super User
Super User

@CLCastroEn , if you are not using legend and not using multiple measures. You can create a color measure and use conditional formating using "Field" Option.

color =
switch ( true(),
FIRSTNONBLANK(Table[commodity],"NA") ="commodity1" && sum(Table[Value]) >500,"lightgreen",
FIRSTNONBLANK(Table[commodity],"NA") ="commodity2" && sum(Table[Value]) >1000,"lightgreen",
/// Add more conditions
"red"
)

 

refer:https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-num...
https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values

pranit828
Community Champion
Community Champion

Hi @CLCastroEn 

 

I would use conditional formatting in this case with % TR values as a percentage above the limit.

 

Did I resolve your issue? Mark my post as a solution! Appreciate your Kudos, Press the thumbs up button!!

 

Regards,
Pranit





PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile

I don't understand, where do I find the conditional formatting? in my formatting tool does not appear.

@pranit828

mahoneypat
Employee
Employee

You can write a measure like this that returns a result-dependent color value you can use in conditional formatting for your bar color.

 

Bar Color = IF([MyMeasure] > 1000, "Green", "Blue")

 

Then highlight your visual and in the Format options for your visual, hit the fx next to bar color and choose the measure you created.

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Thanks Pat.. This is very simple solution you gave.. Happy that its working from me. Thanks a lot. 

This is my first solution ever worked and since i am writing it to you. 🙂

@mahoneypat hello! didn't work for me 😞 could you attach a screenshot of how to do it? Please

Highlight your bar chart, and then find the Data Colors section in the Format pane

mahoneypat_0-1597437453721.png

Click on the fx, and pick Field Value and then the Bar Color Measure.

mahoneypat_1-1597437486936.png

If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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