Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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?
Solved! Go to Solution.
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.
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")
Second, in the bar chart, go to the visual format, add your measure created under the bar color.
Select the measure under Field value style and click OK. Below is the result.
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 @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!
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.
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.
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")
Second, in the bar chart, go to the visual format, add your measure created under the bar color.
Select the measure under Field value style and click OK. Below is the result.
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.
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.
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.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 63 | |
| 55 | |
| 42 | |
| 41 | |
| 23 |
| User | Count |
|---|---|
| 171 | |
| 136 | |
| 119 | |
| 79 | |
| 54 |