Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

formatting based on another column

Hi Power Users,

I'm trying to do conditional formatting in matrix visual for one column  based on another column. 

 

If column1 is > or = Column2 then background of column1 should be Yellow

If column1 is not equal to but close to Column2, background should be Red

If column1 is less than but close to Column2 background should be Black

If column1 very low compared to Column2, background should be Blue

 

I need to do like above, Please help. 

 

Thanks

4 Replies

  • Anonymous , You have to create a color column , but prefer a measure and use that in conditional forammting using field value option

    color column =

    Switch( True() ,

    [column1] >= [Column2] , "Yellow",

    //Add others 

    "red"

    )

     

    color Measure =

    Switch( True() ,

    sum([column1]) >= sum([Column2]) , "Yellow",

    //Add others 

    "red"

    )

     

    Not very clear what do you mean by close to

     

    How to do conditional formatting by measure and apply it on pie?: https://youtu.be/RqBb5eBf_I4

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    This is how I understand your judgment sentence
    If column1 is much larger than column2 (ie column1-column2>=1) or column1=column2, the background color is yellow.
    If column1 is greater than column2 and close to column2 (ie 0<column1-column2<1), the background color is red.
    If column2 is smaller than column2 and close to column2 (that is, -1<column1-column2<0), the background color is black.
    If column1 is much smaller than column2 (ie column1-column2<=-1), the background color is blue.

    Measure = var _tt=MAX('Table'[Column1])-MAX('Table'[Column2])
    return IF(_tt>0&&_tt<1,"Red",IF(_tt=0||(_tt>=1),"Yellow",IF(_tt>-1&&_tt<0,"Black",IF(_tt<=-1,"Blue"))))

     

    Reference: Use conditional formatting in tables

     

     

     

    Best Regards,

    Stephen Tao

     

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

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi 

      Thanks for the response. I can not use MAX function because the columns that i have is percentages. 

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous ,

         

        Sorry I don't quite understand what you mean. Why can't the MAX function be used for percentages? Have you tried it yourself? If it really doesn't work, please tell me what the data looks like, and you can provide me some similar dummy data.

         

        Best Regards,

        Stephen Tao

         

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