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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Daniel_Derbin
Frequent Visitor

Conditional formatting (background color) each cell separately in matrix

Hello, 

 

Im trying to apply logic into matrix but based on different rule for almost each cell in a row.
I'm using currently only one measure to give me percentage result.

 

What i have so far:
matrix new.jpg
Fields.jpg


What the result of formatting should look like:

matrix formatting.jpg

 

Appreciate your help, Dan 🙂

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @Daniel_Derbin,

 

For this you need to create a metric similar to this:

 

 

Formating =
SWITCH (
    TRUE (),
    SELECTEDVALUE ( Table[Record age] ) = "0-30 days"
        && SELECTEDVALUE ( Table[Severity] ) = "Critical"
        && [% of vuln wo Sev] >= 0.92, "Green",
    SELECTEDVALUE ( Table[Record age] ) = "31-60 days"
        && SELECTEDVALUE ( Table[Severity] ) = "Critical"
        && [% of vuln wo Sev] <= 0.08
        && [% of vuln wo Sev] > 0, "Yellow",
    (
        SELECTEDVALUE ( Table[Record age] ) = "0-30 days"
            || SELECTEDVALUE ( Table[Record age] ) = "31-61 days"
    )
        && SELECTEDVALUE ( Table[Severity] ) = "High"
        && [% of vuln wo Sev] >= 0.95, "Green",
    SELECTEDVALUE ( Table[Record age] ) = "61-90 days"
        && SELECTEDVALUE ( Table[Severity] ) = "High"
        && [% of vuln wo Sev] <= 0.05
        && [% of vuln wo Sev] > 0, "Yellow",
    (
        SELECTEDVALUE ( Table[Record age] ) = "0-30 days"
            || SELECTEDVALUE ( Table[Record age] ) = "31-61 days"
            || SELECTEDVALUE ( Table[Record age] ) = "61-90 days"
    )
        && SELECTEDVALUE ( Table[Severity] ) = "Medium"
        && [% of vuln wo Sev] >= 0.95, "Green",
    SELECTEDVALUE ( Table[Record age] ) = "91-180 days"
        && SELECTEDVALUE ( Table[Severity] ) = "Medium"
        && [% of vuln wo Sev] <= 0.05
        && [% of vuln wo Sev] > 0, "Yellow",
    (
        SELECTEDVALUE ( Table[Record age] ) = "0-30 days"
            || SELECTEDVALUE ( Table[Record age] ) = "31-61 days"
            || SELECTEDVALUE ( Table[Record age] ) = "61-90 days"
            || SELECTEDVALUE ( Table[Record age] ) = "91-180 days"
    )
        && SELECTEDVALUE ( Table[Severity] ) = "Low"
        && [% of vuln wo Sev] >= 0.95, "Green",
    SELECTEDVALUE ( Table[Record age] ) = "180-360 days"
        && SELECTEDVALUE ( Table[Severity] ) = "Low"
        && [% of vuln wo Sev] <= 0.05
        && [% of vuln wo Sev] > 0, "Yellow",
    "Red"
)

This may need some adjustments, there is also an option to create a table with the values of your maximum and minimun values if you want I can try and setup that table that would allow you to give you a better editing option in the future.

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

Hi @Daniel_Derbin,

 

For this you need to create a metric similar to this:

 

 

Formating =
SWITCH (
    TRUE (),
    SELECTEDVALUE ( Table[Record age] ) = "0-30 days"
        && SELECTEDVALUE ( Table[Severity] ) = "Critical"
        && [% of vuln wo Sev] >= 0.92, "Green",
    SELECTEDVALUE ( Table[Record age] ) = "31-60 days"
        && SELECTEDVALUE ( Table[Severity] ) = "Critical"
        && [% of vuln wo Sev] <= 0.08
        && [% of vuln wo Sev] > 0, "Yellow",
    (
        SELECTEDVALUE ( Table[Record age] ) = "0-30 days"
            || SELECTEDVALUE ( Table[Record age] ) = "31-61 days"
    )
        && SELECTEDVALUE ( Table[Severity] ) = "High"
        && [% of vuln wo Sev] >= 0.95, "Green",
    SELECTEDVALUE ( Table[Record age] ) = "61-90 days"
        && SELECTEDVALUE ( Table[Severity] ) = "High"
        && [% of vuln wo Sev] <= 0.05
        && [% of vuln wo Sev] > 0, "Yellow",
    (
        SELECTEDVALUE ( Table[Record age] ) = "0-30 days"
            || SELECTEDVALUE ( Table[Record age] ) = "31-61 days"
            || SELECTEDVALUE ( Table[Record age] ) = "61-90 days"
    )
        && SELECTEDVALUE ( Table[Severity] ) = "Medium"
        && [% of vuln wo Sev] >= 0.95, "Green",
    SELECTEDVALUE ( Table[Record age] ) = "91-180 days"
        && SELECTEDVALUE ( Table[Severity] ) = "Medium"
        && [% of vuln wo Sev] <= 0.05
        && [% of vuln wo Sev] > 0, "Yellow",
    (
        SELECTEDVALUE ( Table[Record age] ) = "0-30 days"
            || SELECTEDVALUE ( Table[Record age] ) = "31-61 days"
            || SELECTEDVALUE ( Table[Record age] ) = "61-90 days"
            || SELECTEDVALUE ( Table[Record age] ) = "91-180 days"
    )
        && SELECTEDVALUE ( Table[Severity] ) = "Low"
        && [% of vuln wo Sev] >= 0.95, "Green",
    SELECTEDVALUE ( Table[Record age] ) = "180-360 days"
        && SELECTEDVALUE ( Table[Severity] ) = "Low"
        && [% of vuln wo Sev] <= 0.05
        && [% of vuln wo Sev] > 0, "Yellow",
    "Red"
)

This may need some adjustments, there is also an option to create a table with the values of your maximum and minimun values if you want I can try and setup that table that would allow you to give you a better editing option in the future.

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi MFelix, 

 

That worked as a charm after smal adjustments.
Thank you a lot!! 🙂

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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