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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
jacquelineq
Helper I
Helper I

How to show a different colour for column A

Hi,

 

I have a bar chart and I would like to display column A in red if the value is below column C and green if the value is above column C. How can I achieve that as the colour settings only show 1 option? 

 

power-bi-bar-chart.png

1 ACCEPTED SOLUTION

Hi @jacquelineq ,

Please new a measure:

Color =
VAR _a =
    CALCULATE ( SUM ( 'Table'[Score] ), 'Table'[Scope] = "A" )
VAR _c =
    CALCULATE ( SUM ( 'Table'[Score] ), 'Table'[Scope] = "C" )
RETURN
    IF ( MAX ( 'Table'[Scope] ) = "A", IF ( _a < _c, "Red", "Green" ) )

Use it as a conditional format for the bar color.

vcgaomsft_0-1667784217656.png

result:

vcgaomsft_1-1667784335765.png

Attached PBIX file for reference.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@jacquelineq , if you are using legend , you can not. Use both axis and legend in the axis, and expand. Then Sort on axis and concatenate the label off. Post that you can do conditional formatting 

 

refer with conditional formatting code:Concatenate Label off : https://youtu.be/QgI0vIGIOOk

 

How to do conditional formatting by measure and apply it on pie?
https://www.youtube.com/watch?v=RqBb5eBf_I4&list=PLPaNVDMhUXGYo50Ajmr4SgSV9HIQLxc8L
https://community.powerbi.com/t5/Community-Blog/Power-BI-Conditional-formatting-the-Pie-Visual/ba-p/...
https://amitchandak.medium.com/power-bi-where-is-the-conditional-formatting-option-in-new-format-pan...

@amitchandak Thanks for your reply! 

 

May I know how should I code my measure to compare the values? This is my table:

 

YearScopeTypeScore
2021AType180
2021BType182
2021CType184
2021AType270
2021BType273
2021CType274
2021DType181
2021EType183
2021FType186

Hi @jacquelineq ,

Please new a measure:

Color =
VAR _a =
    CALCULATE ( SUM ( 'Table'[Score] ), 'Table'[Scope] = "A" )
VAR _c =
    CALCULATE ( SUM ( 'Table'[Score] ), 'Table'[Scope] = "C" )
RETURN
    IF ( MAX ( 'Table'[Scope] ) = "A", IF ( _a < _c, "Red", "Green" ) )

Use it as a conditional format for the bar color.

vcgaomsft_0-1667784217656.png

result:

vcgaomsft_1-1667784335765.png

Attached PBIX file for reference.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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