cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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:

What the result of formatting should look like:

1 ACCEPTED SOLUTION
Super User

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

Proud to be a Super User!

Check out my blog: Power BI em Português

2 REPLIES 2
Super User

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

Proud to be a Super User!

Check out my blog: Power BI em Português

Frequent Visitor

Hi MFelix,

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

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - August 2024

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

#### Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

#### Fabric Community Update - September 2024

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

Top Solution Authors
Top Kudoed Authors