Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
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
Solved! Go to Solution.
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.)
I attach a pbix file for your reference.
Best regards,
@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.
Hi,
Thank you, i will try your solution. I comeback later.
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.
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.)
I attach a pbix file for your reference.
Best regards,
@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.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.