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.
Hello Power BI Community,
I am trying to create a conditional format on a matrix. The conditional format I envision will be applied on a row-by-row level.
I am pretty close. I hope you can help me get the football over the goal line.
Here is the link to the data and PBIX. The data is fake but the problem is real.
My output so far.
My Issue
CF Measure is applied on conditional formatting
Goal of CF measure
conditional formatting on a row by row basis
Issues with CF measure
Here is my CF Measure
Solved! Go to Solution.
Hi @Anonymous
I have attached an edited version of the PBIX.
There are two CF measures I tried:
Here are the measures:
CF =
VAR TotalStudents =
[Total Students]
VAR PerformanceLevel =
SELECTEDVALUE ( 'Test and Intervention Hours'[Performance Level] )
VAR DidNotMeetgreaterThan5 =
AND (
PerformanceLevel = "Did Not Meet",
TotalStudents > 5
)
VAR OverrideColour = "red" -- adjust as needed
VAR Color =
IF (
DidNotMeetgreaterThan5,
-- If Did Not Meet & Total Students > 5 then use OverrideColour
OverrideColour,
-- Otherwise use normal rule
VAR SummaryTable =
CALCULATETABLE (
ADDCOLUMNS (
SUMMARIZE (
'Test and Intervention Hours',
Campus[Intervention Teacher Last Name],
'Test and Intervention Hours'[Performance Level]
),
"Students", [Total Students]
),
ALLSELECTED ()
)
VAR MaxValue = MAXX ( SummaryTable, [Students] )
VAR MinValue = MINX ( SummaryTable, [Students] )
VAR Range = MaxValue - MinValue
VAR Shade =
ROUND (
DIVIDE ( TotalStudents - MinValue, Range ) * 120,
0
)
RETURN
"hsla(" & Shade & ", " & "100%" & "," & "90%" & "," & 1
& ")"
)
RETURN
Color
CF v2 =
VAR TotalStudents =
[Total Students]
VAR PerformanceLevel =
SELECTEDVALUE ( 'Test and Intervention Hours'[Performance Level] )
VAR DidNotMeetgreaterThan5 =
AND (
PerformanceLevel = "Did Not Meet",
TotalStudents > 5
)
VAR OverrideColour = "red" -- adjust as needed
VAR Color =
IF (
DidNotMeetgreaterThan5,
-- If Did Not Meet & Total Students > 5 then use OverrideColour
OverrideColour,
-- Otherwise use normal rule
VAR SummaryTable =
FILTER (
CALCULATETABLE (
ADDCOLUMNS (
SUMMARIZE (
'Test and Intervention Hours',
Campus[Intervention Teacher Last Name],
'Test and Intervention Hours'[Performance Level]
),
"Students", [Total Students]
),
ALLSELECTED ()
),
NOT AND (
'Test and Intervention Hours'[Performance Level] = "Did Not Meet",
[Students] > 5
)
)
VAR MaxValue = MAXX ( SummaryTable, [Students] )
VAR MinValue = MINX ( SummaryTable, [Students] )
VAR Range = MaxValue - MinValue
VAR Shade =
ROUND (
DIVIDE ( TotalStudents - MinValue, Range ) * 120,
0
)
RETURN
"hsla(" & Shade & ", " & "100%" & "," & "90%" & "," & 1
& ")"
)
RETURN
Color
Hi @Anonymous
I have attached an edited version of the PBIX.
There are two CF measures I tried:
Here are the measures:
CF =
VAR TotalStudents =
[Total Students]
VAR PerformanceLevel =
SELECTEDVALUE ( 'Test and Intervention Hours'[Performance Level] )
VAR DidNotMeetgreaterThan5 =
AND (
PerformanceLevel = "Did Not Meet",
TotalStudents > 5
)
VAR OverrideColour = "red" -- adjust as needed
VAR Color =
IF (
DidNotMeetgreaterThan5,
-- If Did Not Meet & Total Students > 5 then use OverrideColour
OverrideColour,
-- Otherwise use normal rule
VAR SummaryTable =
CALCULATETABLE (
ADDCOLUMNS (
SUMMARIZE (
'Test and Intervention Hours',
Campus[Intervention Teacher Last Name],
'Test and Intervention Hours'[Performance Level]
),
"Students", [Total Students]
),
ALLSELECTED ()
)
VAR MaxValue = MAXX ( SummaryTable, [Students] )
VAR MinValue = MINX ( SummaryTable, [Students] )
VAR Range = MaxValue - MinValue
VAR Shade =
ROUND (
DIVIDE ( TotalStudents - MinValue, Range ) * 120,
0
)
RETURN
"hsla(" & Shade & ", " & "100%" & "," & "90%" & "," & 1
& ")"
)
RETURN
Color
CF v2 =
VAR TotalStudents =
[Total Students]
VAR PerformanceLevel =
SELECTEDVALUE ( 'Test and Intervention Hours'[Performance Level] )
VAR DidNotMeetgreaterThan5 =
AND (
PerformanceLevel = "Did Not Meet",
TotalStudents > 5
)
VAR OverrideColour = "red" -- adjust as needed
VAR Color =
IF (
DidNotMeetgreaterThan5,
-- If Did Not Meet & Total Students > 5 then use OverrideColour
OverrideColour,
-- Otherwise use normal rule
VAR SummaryTable =
FILTER (
CALCULATETABLE (
ADDCOLUMNS (
SUMMARIZE (
'Test and Intervention Hours',
Campus[Intervention Teacher Last Name],
'Test and Intervention Hours'[Performance Level]
),
"Students", [Total Students]
),
ALLSELECTED ()
),
NOT AND (
'Test and Intervention Hours'[Performance Level] = "Did Not Meet",
[Students] > 5
)
)
VAR MaxValue = MAXX ( SummaryTable, [Students] )
VAR MinValue = MINX ( SummaryTable, [Students] )
VAR Range = MaxValue - MinValue
VAR Shade =
ROUND (
DIVIDE ( TotalStudents - MinValue, Range ) * 120,
0
)
RETURN
"hsla(" & Shade & ", " & "100%" & "," & "90%" & "," & 1
& ")"
)
RETURN
Color
This 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 |
---|---|
10 | |
9 | |
8 | |
7 | |
6 |
User | Count |
---|---|
14 | |
12 | |
11 | |
9 | |
9 |