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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
VagelisVlachos
Frequent Visitor

Change color for bar chart into the measure not in conditional formating

Hello.

 

I have this measure that shows in one bar chart the top10 and bottom 10 of customers by profit.

I want to change the color in the measure for a bar chart when its >0 to green and when its <0 to red.From the conditional formating it goes wrong cause the top 2 is green and all the other are going red.

 

Please help!

 

 

Top/Bottom =
VAR top10 =
    RANKX ( ALL ( DimCustomer[Name] ), [Gross Profit],, ASC )
VAR bot10 =
    RANKX ( ALL ( DimCustomer[Name] ), [Gross Profit],, DESC )
RETURN
    IF ( top10 <= 10 || bot10 <= 10, [Gross Profit], BLANK () )
1 ACCEPTED SOLUTION

Change Qty Color =
VAR PDDate =
     ( [Gross Profit])
RETURN
    IF ( PDDate < 0, "#861B14","#499277")
 
You make this a measure and after you make a conditional formating into "bars" and you pick this in the "What field should we base this on"

View solution in original post

3 REPLIES 3
FreemanZ
Super User
Super User

hi @VagelisVlachos 

RANKX relies on filter context. How does you visual look like?

Χωρίς τίτλοas.png

Change Qty Color =
VAR PDDate =
     ( [Gross Profit])
RETURN
    IF ( PDDate < 0, "#861B14","#499277")
 
You make this a measure and after you make a conditional formating into "bars" and you pick this in the "What field should we base this on"

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.