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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
admin11
Memorable Member
Memorable Member

How to replace script with set back ground color for sales vari % field ?

Hi All

 

I have below expression to give sales vari % :-

Sales Vari % new = divide( [Sales YTD]-[Sales LYTD], [Sales LYTD] )
admin11_0-1642860622948.png
After i set condition for those % >0.0001 color blue , and <0.00001 color red.
 
My question is , how to convert the above condition in script . so that i don't need to click so many step.
 
So that when i use the sales vari % , it will automatic set background color.
 
Paul
1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey @admin11 ,

 

basically, it's not possible to convert the rule-based conditional formatting into a script.

 

What you can consider to create a measure that returns the name of a color llike "red" or "#ffffff" if a certain conditons are met, otherwise the measure will return other colors. You can achieve this by using the SWITCH statement.. Then you can use this measure and the value-based conditional formatting.

But, as the conditional formatting is tight to the visual you have to enable conditional formatting whenever you use your "Sales var ..." measure.

 

Hopefully, this will help to tackle your challenge.

 

Regards,

Tom 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

1 REPLY 1
TomMartens
Super User
Super User

Hey @admin11 ,

 

basically, it's not possible to convert the rule-based conditional formatting into a script.

 

What you can consider to create a measure that returns the name of a color llike "red" or "#ffffff" if a certain conditons are met, otherwise the measure will return other colors. You can achieve this by using the SWITCH statement.. Then you can use this measure and the value-based conditional formatting.

But, as the conditional formatting is tight to the visual you have to enable conditional formatting whenever you use your "Sales var ..." measure.

 

Hopefully, this will help to tackle your challenge.

 

Regards,

Tom 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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