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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

How to change background color in matrix table based on values

Hello everyone, 

 

Haven't done anything similar before, I am currious if I am able to change background color based on value in matrix table. 
I have country column as you can see from image and two countries are columns values (spain and portugal) and some values about counties. 
I would like to have red color if the values are not matching and green if the values are matching. 
I have tried few things but the meausre I was creating wasn't good.

Capture.PNG

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , You need to create a measure like , assume you have measure M1

 

color =

var _diff = if( calculate([M1] , Table[country] ="spain") = calculate([M1] , Table[country] ="Portugal") ,1,0)

return

if(_diff =1, "Green", "Red")

 

Use this in conditional formatting using filed value option

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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , You need to create a measure like , assume you have measure M1

 

color =

var _diff = if( calculate([M1] , Table[country] ="spain") = calculate([M1] , Table[country] ="Portugal") ,1,0)

return

if(_diff =1, "Green", "Red")

 

Use this in conditional formatting using filed value option

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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

This was very helpful, thanks a lot!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors