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! Request now

Reply
psorel
Helper I
Helper I

Conditionnal formatting on matrix visuel and percentage of variation

Hello, I have a matrix visualization containing data from month M and previous months up to M-5 in columns .
I'm creating M-1/M-2, M-2/M-3 variance measurements in %.
Is it possible to apply visual formatting to these variance columns according to the following criteria:

- red variation +/- 50%
- orange variation +/- 25%
- green +/- 10%

Thank You

1 ACCEPTED SOLUTION
DataNinja777
Super User
Super User

Hi @psorel ,

 

In order to conditionally format the % variance, you can create a previous month measure like below:

Previous Month = calculate([Current Month],DATEADD('Date'[Date],-1,Month))

Then, create a variance measure like below:

Variance = divide([Current Month],[Previous Month])

Finally, you can add a color measure like below:

Variance Color = 
VAR r   = [Variance]                  -- Current / Previous
VAR dev = IF( ISBLANK(r), BLANK(), ABS( r - 1 ) )  -- distance from 1.0
RETURN
SWITCH(
    TRUE(),
    ISBLANK(dev), BLANK(),
    dev >= 0.50, "#FF0000",   -- red  (±50% or more)
    dev >= 0.25, "#FFA500",   -- orange (±25–50%)
    dev >= 0.10, "#00B050",   -- green (±10–25%)
    "#D9D9D9"                 -- gray (within ±10%)
)

 You can use this color measure to conditionally format the [Variance] and [Variance-1] measures, and the resultant conditional formatting is as shown below:  
([Variance-1] was added to clearly demonstrate the conditional coloring matches the conditions set because it is not clear to see that from [Variance] measure alone.)

DataNinja777_0-1760500688568.png

 

 

I attach a pbix file for your reference. 

 

Best regards,

 

View solution in original post

6 REPLIES 6
parry2k
Super User
Super User

@psorel, glad to hear. When you get a chance, please click "Accept as solution" so that others can find this post.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

psorel
Helper I
Helper I

@DataNinja777 @parry2k  
Thank you for your work. It's perfect !!!

psorel
Helper I
Helper I

Hi, 
Thank you, i will try your solution. I comeback later.

v-hjannapu
Community Support
Community Support

Hi @psorel,

I would also take a moment to thank @DataNinja777  , @parry2k  for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.
 

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.

Regards,
Community Support Team.

DataNinja777
Super User
Super User

Hi @psorel ,

 

In order to conditionally format the % variance, you can create a previous month measure like below:

Previous Month = calculate([Current Month],DATEADD('Date'[Date],-1,Month))

Then, create a variance measure like below:

Variance = divide([Current Month],[Previous Month])

Finally, you can add a color measure like below:

Variance Color = 
VAR r   = [Variance]                  -- Current / Previous
VAR dev = IF( ISBLANK(r), BLANK(), ABS( r - 1 ) )  -- distance from 1.0
RETURN
SWITCH(
    TRUE(),
    ISBLANK(dev), BLANK(),
    dev >= 0.50, "#FF0000",   -- red  (±50% or more)
    dev >= 0.25, "#FFA500",   -- orange (±25–50%)
    dev >= 0.10, "#00B050",   -- green (±10–25%)
    "#D9D9D9"                 -- gray (within ±10%)
)

 You can use this color measure to conditionally format the [Variance] and [Variance-1] measures, and the resultant conditional formatting is as shown below:  
([Variance-1] was added to clearly demonstrate the conditional coloring matches the conditions set because it is not clear to see that from [Variance] measure alone.)

DataNinja777_0-1760500688568.png

 

 

I attach a pbix file for your reference. 

 

Best regards,

 

parry2k
Super User
Super User

@psorel you can create a measure for color formatting and use it as field value in conditional formatting:

 

Feel free to tweak the code as per your business needs.

 

Color =
VAR __Variance = [Variance % Measure]
RETURN
SWITCH ( 
   TRUE (),
   __Variance >= .1, "Green",
   __Variance >= .25, "Orange",
   "Red"
)

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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.

Top Solution Authors