Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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 Manager | Audits |
Fred | 20 |
George | 1 |
Ginny | 80 |
Ron | 2 |
Percy | 20 |
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.
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
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.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingThis is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
11 | |
9 | |
8 | |
6 | |
5 |
User | Count |
---|---|
19 | |
17 | |
11 | |
9 | |
9 |