Forum Discussion

LauraBueno's avatar
LauraBueno
Helper III
6 years ago

conditional format matrix

Hello everyone

I'm trying to apply conditional formatting to an array depending on the values displayed (more negative values will be red and moving green as the values become more positive). However, conditional formatting is applied on all columns and I would like this comparison to be displayed in the array. Is there any way to do this?

This is the table I have. I would like to display the color format (red - green) for the delta vs Reference variable for each of the swatches. However, when I apply conditional formatting, the color is applied by comparing all swatches (since the variable is the same). Is there a way to break it by column (shown as in the table below)?

table.png

Thank you

Laura

4 Replies

  • LauraBueno 

    not sure I got it. But you can create a color measure on dimension values and measure values like this

     

    Color Date = if(FIRSTNONBLANK(Table[date],TODAY()) <today(),"lightgreen","red")
    if(FIRSTNONBLANK(Table[Value],"true") "true","green","red")
    
    
    Color sales = if(AVERAGE(Sales[Sales Amount])<170,"green","red")
    Color Year = if(FIRSTNONBLANK(Table[Year],2014) <=2016,"lightgreen",if(FIRSTNONBLANK(Table[Year],2014)>2018,"red","yellow"))
    
    Color  = if(FIRSTNONBLANK(Table[Year],2014) <=2016 && AVERAGE(Sales[Sales Amount])<170 
    ,"lightgreen",if(FIRSTNONBLANK(Table[Year],2014)>2018,"red","yellow"))
    Color sales = if([Sales Today] -[sales yesterday]>0,"green","red")

     

     

    And this can be used in conditional formatting after selecting "Field". Once you use it one column , it will be there for all samples

     

    refer:
    https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-numbers-in-the-column
    https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting

  • AllisonKennedy's avatar
    AllisonKennedy
    Community Champion

    You could achieve close to what you want by creating a rank measure that ranks within each Sample, and using that RANK measure as the value for the conditional formatting. So your table would be formatted with 4 different colour rather than a relative scale. So you could easily see which row in each column/array is the highest and lowest, but not easily see by how much they differ.

    Here's one resource for RANKX, but there's lots of ways to use it, including putting it in MEASURE instead of column: 

    https://databear.com/how-to-use-the-dax-rankx-function-in-power-bi/

     

    Has this post solved your problem? Please mark it as a solution so that others can find it quickly and to let the community know your problem has been solved. 

     

    If you found this post helpful, please give Kudos.

    I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 

    https://sites.google.com/site/allisonkennedycv

  • v-xicai's avatar
    v-xicai
    Community Support

    Hi LauraBueno ,

     

    Did you choose the right field to set conditional format? You may select on the [delta vs Reference], right-click or select the down-arrow next to the field in the Values well that you want to format. Select Conditional formatting, and then select the type of formatting to apply.

     

    For reference:

    Use conditional formatting in tables

     

    Best Regards,

    Amy 

     

    Community Support Team _ Amy

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • v-xicai's avatar
    v-xicai
    Community Support

    Hi LauraBueno   ,

     

    Does that make sense? If so, kindly mark the proper reply as a solution to help others having the similar issue and close the case. If not, let me know and I'll try to help you further.

     

    Best regards

    Amy