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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Anonymous
Not applicable

Conditional formatting based on slicer value

 

I have a matrix that is a budget to actual comparision. My variance column is a meausre that i created. Then i have months data rolling into this depenidng on the month that is slected on the slicer. The fiscal year starts July so that month number is 1. 

 

What i am trying to do it have the variance column highlight red if over the expected amount. The expected amount would simply be caulculated like if the slicer is ending in October (#4 month) then the excepted amount would be 4/12 or 33%. So if that percentage in the variance column is above 33% then it would be highlighted red. See below for pictures.

 

matrixmatrixslicerslicer

 

Any suggestions is greatly appreciated. thanks!

1 ACCEPTED SOLUTION
v-lili6-msft
Community Support
Community Support

hi, @Anonymous

After my research, you could do these as below:

Step1:

this is variance measure

variance = CALCULATE(SUM(Table1[Revenue]))/CALCULATE(SUM(Table1[Revenue Budget]))

Then we add two more other measures

Number months = CALCULATE((DATEDIFF(MIN(Table1[Date]),MAX(Table1[Date]),MONTH)+1)/12,ALLEXCEPT(Table1,Table1[Date]))
Conditional = IF([variance]>[Number months],1,2)

Step2:

select matrix visual and right-click field variance, Conditional formatting ->Background color

1.PNG

 

Step3:

Select Format by Rules -> Based on field measure Conditional ->Rules if value is 1

2.PNG

Result:

3.PNG

here is my demo, please try it.

https://www.dropbox.com/s/j4h35fcpyvu7jir/Conditional%20formatting%20based%20on%20slicer%20value.pbi...

 

Best Regards,

Lin

 

 

 

 

 

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-lili6-msft
Community Support
Community Support

hi, @Anonymous

After my research, you could do these as below:

Step1:

this is variance measure

variance = CALCULATE(SUM(Table1[Revenue]))/CALCULATE(SUM(Table1[Revenue Budget]))

Then we add two more other measures

Number months = CALCULATE((DATEDIFF(MIN(Table1[Date]),MAX(Table1[Date]),MONTH)+1)/12,ALLEXCEPT(Table1,Table1[Date]))
Conditional = IF([variance]>[Number months],1,2)

Step2:

select matrix visual and right-click field variance, Conditional formatting ->Background color

1.PNG

 

Step3:

Select Format by Rules -> Based on field measure Conditional ->Rules if value is 1

2.PNG

Result:

3.PNG

here is my demo, please try it.

https://www.dropbox.com/s/j4h35fcpyvu7jir/Conditional%20formatting%20based%20on%20slicer%20value.pbi...

 

Best Regards,

Lin

 

 

 

 

 

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi @v-lili6-msft

 

Thank you! That works great.  And thanks for the indepth step by step. It was the nice finishing touch to the report.

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.