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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

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 @Anonymous ,

 

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
Community Champion
Community Champion

Hi @Anonymous 

 

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 @Anonymous ,

 

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.

 

Anonymous
Not applicable

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 @Anonymous ,

 

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.

 

 

Anonymous
Not applicable

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 @Anonymous ,

 

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.

 

Anonymous
Not applicable

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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.