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
obriaincian
Resolver I
Resolver I

Matrix Conditional Formatting

Hi All,

 

I've a problem I'm struggling with.

 

I have 2 tables

 

Table 1

ID                                        
11
22
33
44

 

Table 2

ID                                         Year                      
112021
222021
332022
442022
662023
772024
882024
992024
10102025
11112025

 

Matrix Visual (OUTPUT)

 2021                      20222023                            2024          2025          
ID Count                  22132

 

 

What I'd like if the ID from ID count is in Table 1 I'd like to color the cell background green.

 

I tried to do this by going to "cell elements" and entering the below formula for the background color and where the result is >= 1 then color green.

 

 

 

measure = 
COUNTX(FILTER('Table1','Table1'[ID]= SELECTEDVALUE('Table2'[ID])),'Table1'[ID])

 

 

4 REPLIES 4
v-cgao-msft
Community Support
Community Support

Hi @obriaincian ,

 

Please try this:

Color = 
VAR _table = CALCULATETABLE(VALUES('Table2'[ID]))
VAR _color = IF(COUNTROWS(INTERSECT('Table1',_table))>0,"Green")
RETURN
_color

vcgaomsft_0-1675067116390.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Hi @v-cgao-msft,

 

Thank you for the solution. Unfortunately I'm getting the below error when using your code

 

Each table argument of 'INTERSECT' must have the same number of columns.

 

Any workaround for this?

 

Hi @obriaincian ,

 

Please try:

Color = 
VAR _table = CALCULATETABLE(VALUES('Table2'[ID]))
VAR _color = IF(COUNTROWS(INTERSECT(DISTINCT('Table1'[ID]),_table))>0,"Green")
RETURN
_color

vcgaomsft_1-1675126226222.png

vcgaomsft_0-1675126197785.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Pragati11
Super User
Super User

Hi @obriaincian ,

 

I don't think I understand your requirement. What do you mean by this statement of yours?

"What I'd like if the ID from ID count is in Table 1 I'd like to color the cell background green."

 

This statement doesn't make sense as the values in Table 1 are different (2 digit ID value) to what you have in your matrix visual. You matrix visual has a count of ID column not the actual value from ID column.

 

Kindly add more details to your requirement.

 

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

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.