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

Join 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.

Reply
rsramos78
Regular Visitor

Matrix - Conditional formatting based on the result of a DAX function

Hi, 

I have the below Matrix and want to change the background color of the line "+/- Var" only where the values are negative (<0). (If negative = red, if positive = green)

However the line is a calculation created by the DAX function below:

Values =
VAR result =
CALCULATE (
SUM ( 'BDR Combined'[Value] ),
VALUES ( 'BDR Type'[Type]),
VALUES ( 'BDR Months'[Month] )
)
VAR list =
SUMMARIZE ( ALLSELECTED ( 'BDR Combined'), [Year], [Type], "Result", result )
RETURN
IFERROR (IF(
result <> BLANK (),
result,
VAR Pipe =
CALCULATE ( SUM ( 'BDR Combined'[Value] ), 'BDR Type'[Type] = "Pipeline" )
VAR Tgt =
CALCULATE ( SUM ( 'BDR Combined'[Value] ), 'BDR Type'[Type] = "Target" )
RETURN
SWITCH (
SELECTEDVALUE ( 'BDR Type'[Type] ),
"+/- Var", Pipe - Tgt,
"% Var",( Pipe / Tgt ) * 100,
BLANK ()
)
),bLANK())

rsramos78_0-1639686037773.png

 

How could I achieve it?

Thanks in advance!

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

create a "sister" measure that outputs the desired color names, and then use that as the basis for the conditional formatting of the main measure value in the matrix.

View solution in original post

2 REPLIES 2
rsramos78
Regular Visitor

Hi @lbendlin , I've followed this path and was able to make it to work.

Thanks,

lbendlin
Super User
Super User

create a "sister" measure that outputs the desired color names, and then use that as the basis for the conditional formatting of the main measure value in the matrix.

Helpful resources

Announcements
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 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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