Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
corpsikumar
Helper I
Helper I

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 4
v-stephen-msft
Community Support
Community Support

Hi @corpsikumar ,

 

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"))))

Screenshot 2021-06-17 174925.pngScreenshot 2021-06-17 174845.png

 

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.

 

 

Hi 

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

Hi @corpsikumar ,

 

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.

amitchandak
Super User
Super User

@corpsikumar , 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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.