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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
DMB1
Frequent Visitor

Conditional Formatting Table Background Colour - (IF Text & Value then color)

I have a table like the following.  I want to set a conditional format background color based on the name and numerical value.  Multiple rules based on the name in the first column and value in the second.

 

For Example:

If Audit Manager = "Fred"  & Audits = 20  then  green

If Audit Manager = "Fred" & Audits <20 then yellow

If Audit Manager = Fred & Audits >20 then Red

If Audit Manager = George & Audits =3 then Green

If Audits Manager = George & Audits ❤️ then yellow

If Audit Manager = George & Audits >3 then Red

 

Audit ManagerAudits
Fred20
George1
Ginny80
Ron2
Percy20

 

I think I need a measure to refer to when applying the conditional formating on the table but not entirely sure of code that is needed.

 

It looks like it should be easy,  but please note a value of 3 for one name might be red but for another name it might be green.  I need separate rules based on the names and numbers.

1 REPLY 1
edhans
Super User
Super User

Hi @DMB1 - this will work. Note that the yellow isn't showing up great on my image, but George is indeed yellow as i it is 1. Fred is also green, which is kind of dark. 

Tracked Manager = 
VAR varManagerName = MAX('Table'[Audit Manager])
VAR varAudits = MAX('Table'[Audits])
VAR Result = 
    SWITCH(
        TRUE(),
        AND(varManagerName = "Fred", varAudits = 20), "green",
        AND(varManagerName = "Fred", varAudits < 20), "yellow",
        AND(varManagerName = "Fred", varAudits > 20), "red",
        AND(varManagerName = "George", varAudits = 3), "green",
        AND(varManagerName = "George", varAudits < 3), "yellow",
        AND(varManagerName = "George", varAudits > 3), "red"
    )
RETURN
    Result

edhans_0-1610047520551.png

 

Note you can replace red/green/yellow with hex colors, so the following works. You must remember the # sign for hex numbers:

Tracked Manager = 
VAR varManagerName = MAX('Table'[Audit Manager])
VAR varAudits = MAX('Table'[Audits])
VAR Result = 
    SWITCH(
        TRUE(),
        AND(varManagerName = "Fred", varAudits = 20), "green",
        AND(varManagerName = "Fred", varAudits < 20), "#FFD300",
        AND(varManagerName = "Fred", varAudits > 20), "red",
        AND(varManagerName = "George", varAudits = 3), "green",
        AND(varManagerName = "George", varAudits < 3), "#FFD300",
        AND(varManagerName = "George", varAudits > 3), "red"
    )
RETURN
    Result

That gives you a darker yellow for example. 

The conditional format for the font color is this, where "Tracked Manager" is the measure name I chose.

edhans_1-1610047664335.png

 

 

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.