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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join 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 is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

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.