Forum Discussion

Slabbos's avatar
Slabbos
Frequent Visitor
3 years ago
Solved

Conditional Formatting in Matrix with Measures Grouped by Columns

Hi All,   Hope you can help.   I am trying to wrap my head around Conditional formatting using a gradient for a Matrix that has Columns based off Measures. The gradient conditional formatting is...
  • v-yueyunzh-msft's avatar
    v-yueyunzh-msft
    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