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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Libbyb23
Resolver I
Resolver I

Bar Graph Color Formatting Help

Hi,

Is there a way on a bar graph to have the top 3 (by greatest value) be green and the remaining bars be black?

Libbyb23_0-1734623724065.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Libbyb23 ,

 

Thanks for your reply.

I understood your requirement and here's the workaround with a sample.

In below scenario, we want the bars of Tom, David and Alex are green, and others are black.

vstephenmsft_0-1734923599426.png

You can use the conditional formatting feature.

First, create a measure to return the colors.

Measure = var _rank=RANKX(ALL('Table'),CALCULATE(SUM('Table'[Sale])),,DESC,Dense)
return IF(_rank<=3,"green","black")

vstephenmsft_1-1734923688531.png

Second, in the bar chart, go to the visual format, add your measure created under the bar color.

vstephenmsft_2-1734923720725.png

vstephenmsft_3-1734923753676.png

Select the measure under Field value style and click OK. Below is the result.

vstephenmsft_4-1734923768233.png

Reference:

Apply conditional table formatting in Power BI - Power BI | Microsoft Learn

RANKX function (DAX) - DAX | Microsoft Learn

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

7 REPLIES 7
Uzi2019
Super User
Super User

Hi @Libbyb23 

 

Check below video for conditional formatting of bar chart

https://www.youtube.com/watch?v=lpdQmcUZATs

https://www.youtube.com/watch?v=p88TaEX8H0E


https://www.youtube.com/watch?v=MItQGef79Lc

 

I hope I answered your question!

 

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!
Anonymous
Not applicable

Hi @Libbyb23 ,

 

Thanks for reaching out. I need to confirm that if you want to change the color of the bars in a single bar chart through conditional formatting in a single bar chart. Let's say there's a four-bar in this single bar chart, the first three are green and the fourth is black. Since your screenshot has four bar charts, which confuses me.

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Sorry. It would be a mulitbar chart and I need to change the bars to highlight the ones that are the top 3.

Libbyb23_0-1734701297254.png

 

Anonymous
Not applicable

Hi @Libbyb23 ,

 

Thanks for your reply.

I understood your requirement and here's the workaround with a sample.

In below scenario, we want the bars of Tom, David and Alex are green, and others are black.

vstephenmsft_0-1734923599426.png

You can use the conditional formatting feature.

First, create a measure to return the colors.

Measure = var _rank=RANKX(ALL('Table'),CALCULATE(SUM('Table'[Sale])),,DESC,Dense)
return IF(_rank<=3,"green","black")

vstephenmsft_1-1734923688531.png

Second, in the bar chart, go to the visual format, add your measure created under the bar color.

vstephenmsft_2-1734923720725.png

vstephenmsft_3-1734923753676.png

Select the measure under Field value style and click OK. Below is the result.

vstephenmsft_4-1734923768233.png

Reference:

Apply conditional table formatting in Power BI - Power BI | Microsoft Learn

RANKX function (DAX) - DAX | Microsoft Learn

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Hi,

For some reason, when I try to select the color coding measure I created using your dax.

Libbyb23_0-1734975258314.png

 

Anonymous
Not applicable

Hi @Libbyb23 ,

 

Is your issue that you can't select the measure under 'What field should we base this on?'?

Please provide more details about the issue, in my example, click on the down arrow to get the fields.

vstephenmsft_0-1735005157364.png

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

HI, 

I am able to see the measure but not able to select it. I click on the measure and it doesnt populate in the field.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.