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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
3mmanuel_12
Regular Visitor

Conditional Formatting - Bar Chart from Field values

Hello All,

 

Can anyone help me.

I have a bar chart to show SLA category. 

I need to implement a conditional formatting based on the SLA Policies. My issue is all measures work fine but the bar does not match with the appropriate color. 

Note that the average time is in Hours 

 

See image below.

3mmanuel_12_0-1773384541425.png

Thanks for your support.

9 REPLIES 9
v-saisrao-msft
Community Support
Community Support

HI @3mmanuel_12,

Checking in to see if your issue has been resolved. let us know if you still need any assistance.

 

Thank you.

grazitti_sapna
Super User
Super User

Hi @3mmanuel_12 , 
Your measure should look like below(as you memtioned it's working fine)

SLA Color = 
VAR AvgHours = [Average Time Hours]

RETURN
SWITCH(
TRUE(),
AvgHours <= 24, "#28A745", -- Green
AvgHours <= 48, "#FFC107", -- Yellow
AvgHours > 48, "#DC3545", -- Red
"#808080" -- Default Grey
)

Now follow the below steps: 

In your Bar Chart:

  1. Select the visual

  2. Go to Format Pane

  3. Expand Data Colors

  4. Click fx

  5. Choose: Format by → Field value
    Based on field → SLA Color

This should fulfill your requirement 

🌟 I hope this solution helps you unlock your Power BI potential! If you found it helpful, click 'Mark as Solution' to guide others toward the answers they need.

💡 Love the effort? Drop the kudos! Your appreciation fuels community spirit and innovation.

🎖 As a proud SuperUser and Microsoft Partner, we’re here to empower your data journey and the Power BI Community at large.

🔗 Curious to explore more? [Discover here].

Let’s keep building smarter solutions together!

 

Thanks for your answer.

My measure is something like that.

 

CF Resolution Target =
VAR _value=[Avg Resolution Time]- [Tickets Resolution Target]
RETURN
IF(
    _value>0,"Red", "Green"
)
 
As you see in the image , in the table this measure returns the expected value Green or Red based on the condition.
But it does not works in the bar chart.
I used the same process as you mentioned above to apply color format

if you put hex code in measure it should work, select the colour from conditional format options visualization based on feild value 

I already use hex code for color but still the same issues.

 

can you please try the measure using switch function,  as suggested by @grazitti_sapna . it always works for me. 

3mmanuel_12_0-1773391449272.png

If you look at my measure and the bar chart. I added the color value as data label.

As you can see the measure returns the exact value that i need. But the bar chart color does not reflect the same color.

HI @3mmanuel_12,

Have you had a chance to review the solution we shared earlier? If the issue persists, feel free to reply so we can help further.

 

Thank you.

Hi @3mmanuel_12,

Thank you @grazitti_sapna @AnalyticPulse, for your insights,

I reproduced the scenario using sample data in Power BI Desktop and was able to observe the same behavior where the measure returns the correct Red/Green values, but the column chart color does not reflect the same result.

 

Thank you.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.