Forum Discussion
Need To create conditional formatting for Donut chart for Tied Values
Hi All,
I need to show different shades of Yellow color pallete in donut chart for top 5 categories but I have tied values and they are coming under same color, but the client wants different shades of yellow.
What I want here is different color for all 5 with different shades of yellow.
Hi Anonymous
The issue isn’t with your color SWITCH it’s that your current rank treats tied values as identical.
To assign different shades of yellow to tied top-5 items, you must generate a rank where ties are intentionally broken.
You can do that by creating a Unique Rank measure that sorts by value first, and then uses a secondary stable key (like Category name) to break ties:
Unique Rank = RANKX( ALL('Table'[Category]), [YourValueMeasure] * 1.0 + (1e-10 * RANKX(ALL('Table'[Category]), 'Table'[Category], , ASC)), , DESC, DENSE )This guarantees that even if multiple categories have the same value, they will still receive ranks 1, 2, 3, 4, 5 instead of all being Rank 1.
Then your color measure will work correctly:
Color = SWITCH( [Unique Rank], 1, "#FFF7A6", 2, "#FFE875", 3, "#FFD84A", 4, "#FFC61A", 5, "#FFB800", "#D9D9D9" )This approach ensures different shades for tied values and keeps the donut chart dynamic for changing Top 5 categories.
I hope this information is helpful. If you have any further questions, please let us know. we can assist you further.Regards,
Microsoft Fabric Community Support Team.
17 Replies
- parry2k
Super User
Anonymous, there is a bit of a hack you can do, although Donut Chart doesn't allow conditional formatting, you can use a tree map, apply rule-based conditional formatting, and then convert it to a donut chart.
Color Measure = VAR __Rank = [Your Rank Measure] --or whatever measure that you want the color based on RETURN SWITCH ( __Rank, 1, "Green", 2, "Yellow", 3, "Red", 4, "Grey" )Create tree map, use chemistry on column and measure on value, go to format pane -> color -> fx
Pick format style as Field value and color measure in the based on:
Once conditional formatting is applied, change the tree map to a donut chart, and that will take care of it.
- AnonymousNot applicable
But this doesn't solves the tied values different color requirement.
- johnbarson5New Member
You can solve this by using field-based conditional formatting instead of a single color scale.
Since the values are tied, Power BI will assign the same shade unless you force different colors through a DAX rule.Create a simple color measure that assigns a unique yellow HEX code for each rank:
Rank 1 → #FFF7A6
Rank 2 → #FFE875
Rank 3 → #FFD84A
Rank 4 → #FFC61A
Rank 5 → #FFB800
Then apply it using:
Format → Data Colors → fx → Format by Field value → select your color measure
This forces the donut chart to show different shades even when values are identical.
I had the same issue while charting category usage for a kid-friendly creative game like Toca Boca World , where multiple features had the same numbers. Rank-based color formatting fixed it and made the visualization clearer for the client.
- PhilipTreacy
Super User
Hi johnbarson5
Where are you seeing this ? My Donut visual does not allow CF to be set via fx
Regards
Phil
- AnonymousNot applicable
Inthis way if I have tied values they will fall under same color and that is not what we want.
- PhilipTreacy
Super User
Anonymous
The Donut visual doesn't have an option for Cond Formatting.
How are you setting the colors now (in the image you provided)?
What about setting colors by hand :
Click on More colors and choose your shades of yellow? But I guess if you are trying to show Top 5 these categories will change and thus mess up your chosen colors?
You can use a Treemap which does allow you to use Conditional Formatting to set colors?
Phil
- AnonymousNot applicable
I have > 50 categorries can''t define the color to each one them need dynamic on the basis of top 5 categories that keep on changing
- ThomasWeppler
Impactful Individual
Anonymous
Have you tried my or johbarson5 solution? They should solve it even when your top 5 changes?
- parry2k
Super User
It should depends how you have written your measure. T is hard to tell with a simple answer that is not working, provide bit more context, what have you done, how you are visualization the data, columns and measures etc or provide a sample pbix file.
- ThomasWeppler
Impactful Individual
Hi Tushar
Select the visual you want to change.Go to view and click customize current theme.
Change the colors to different shades of yellow. If you need to find different shades of yellow that are nice to look at than just google it or ask chatgpt.
I hope this help. 🙂 - AnonymousNot applicable
Pragati11 can you help here please
- v-karpurapud
Community Support
Hi Anonymous
Thanks for reaching out to the Microsoft fabric community forum.
I would also take a moment to thank johnbarson5 , ThomasWeppler , PhilipTreacy and parry2k , for actively participating in the community forum and for the solutions you’ve been sharing in the community forum.
I hope the information provided helps you to fix the issue. If you still have any questions or need more help, feel free to reach out. We’re always here to support you
Best Regards,
Community Support Team- AnonymousNot applicable
Hi Team,
The issue is still not resolved can you please suggest few more options to resolve it?- v-karpurapud
Community Support
Hi Anonymous
The issue isn’t with your color SWITCH it’s that your current rank treats tied values as identical.
To assign different shades of yellow to tied top-5 items, you must generate a rank where ties are intentionally broken.
You can do that by creating a Unique Rank measure that sorts by value first, and then uses a secondary stable key (like Category name) to break ties:
Unique Rank = RANKX( ALL('Table'[Category]), [YourValueMeasure] * 1.0 + (1e-10 * RANKX(ALL('Table'[Category]), 'Table'[Category], , ASC)), , DESC, DENSE )This guarantees that even if multiple categories have the same value, they will still receive ranks 1, 2, 3, 4, 5 instead of all being Rank 1.
Then your color measure will work correctly:
Color = SWITCH( [Unique Rank], 1, "#FFF7A6", 2, "#FFE875", 3, "#FFD84A", 4, "#FFC61A", 5, "#FFB800", "#D9D9D9" )This approach ensures different shades for tied values and keeps the donut chart dynamic for changing Top 5 categories.
I hope this information is helpful. If you have any further questions, please let us know. we can assist you further.Regards,
Microsoft Fabric Community Support Team.
- v-karpurapud
Community Support
Hi Anonymous
I wanted to check if you’ve had a chance to review the information provided. If you have any further questions, please let us know. Has your issue been resolved? If not, please share more details so we can assist you further.
Thank You.