Forum Discussion

3mmanuel_12's avatar
3mmanuel_12
Regular Visitor
5 months ago
Solved

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.

Thanks for your support.

9 Replies

  • 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!

     

    • 3mmanuel_12's avatar
      3mmanuel_12
      Regular Visitor

      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
      • AnalyticPulse's avatar
        AnalyticPulse
        Solution Sage

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