Forum Discussion
Need To create conditional formatting for Donut chart for Tied Values
- 9 months ago
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.
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
Hi Team,
The issue is still not resolved can you please suggest few more options to resolve it?
- v-karpurapud9 months ago
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.