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.
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
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
- ThomasWeppler9 months ago
Impactful Individual
Anonymous
Have you tried my or johbarson5 solution? They should solve it even when your top 5 changes?- Anonymous9 months agoNot applicable
Yes I did as I have several donut chart with different color gradient, That solution didn't work
- PhilipTreacy9 months ago
Super User
Anonymous
Yes I said as much in my response.
As Donut Charts do not have the ability to apply Cond Formatting via fx rules/measures (as I also pointed out), have you tried the suggestion from ThomasWeppler ?
Or use a Treemap which will allow CF via measures?
Regards
Phil