Forum Discussion
Conditional Formatting in Matrix with Measures Grouped by Columns
- 3 years ago
Hi , Slabbos
If you want to show the two color you can try to add some judgement in dax code , like this:
Measure 2 = var _rankx = rankx(ALL('Table'[Brand]),CALCULATE( SUM('Table'[Value])),,DESC,Dense) var init_color = 0.5 var _end_color =FORMAT( ((1-init_color)/(COUNTROWS(ALLSELECTED('Table'[Brand]))/2) )*_rankx , "0%") var _end_color2 =FORMAT((COUNTROWS(ALLSELECTED('Table'[Brand]))-_rankx)*(init_color/(COUNTROWS(ALLSELECTED('Table'[Brand]))/2))+init_color,"0%") return IF(_rankx< COUNTROWS(ALLSELECTED('Table'[Brand]))/2 , "hsl(80,100%,"&_end_color&")", "hsl(0,100%,"&_end_color&")")Then we can get this:
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi,
Thank You, I get the Idea, and I may be able to work with this. But it seems your solution is for 1 colour only. I would like to have it be a gradient from Green(Highest Value) to Red(Lowest Value).
Will play around and let you know if I can figure it out.
Hi , Slabbos
If you want to show the two color you can try to add some judgement in dax code , like this:
Measure 2 =
var _rankx = rankx(ALL('Table'[Brand]),CALCULATE( SUM('Table'[Value])),,DESC,Dense)
var init_color = 0.5
var _end_color =FORMAT( ((1-init_color)/(COUNTROWS(ALLSELECTED('Table'[Brand]))/2) )*_rankx , "0%")
var _end_color2 =FORMAT((COUNTROWS(ALLSELECTED('Table'[Brand]))-_rankx)*(init_color/(COUNTROWS(ALLSELECTED('Table'[Brand]))/2))+init_color,"0%")
return
IF(_rankx< COUNTROWS(ALLSELECTED('Table'[Brand]))/2 , "hsl(80,100%,"&_end_color&")", "hsl(0,100%,"&_end_color&")")
Then we can get this:
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
- Slabbos3 years agoFrequent Visitor
Hi,
Thank You. That is it. Just 1 Slight change, you didnt use _end_color2. After changing that it works perfectly. Thanks again for your help.
Measure 4 = var _rankx = rankx(ALL('Table'[Brand]),CALCULATE( SUM('Table'[Value])),,DESC,Dense) var init_color = 0.5 var _end_color =FORMAT( ((1-init_color)/(COUNTROWS(ALLSELECTED('Table'[Brand]))/2) )*_rankx , "0%") var _end_color2 =FORMAT((COUNTROWS(ALLSELECTED('Table'[Brand]))-_rankx)*(init_color/(COUNTROWS(ALLSELECTED('Table'[Brand]))/2))+init_color,"0%") return IF(_rankx< COUNTROWS(ALLSELECTED('Table'[Brand]))/2 , "hsl(80,100%,"&_end_color&")", "hsl(0,100%,"&_end_color2&")")