Forum Discussion

admin11's avatar
admin11
Icon for Memorable Member rankMemorable Member
4 years ago
Solved

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] )
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
  • 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 

1 Reply

  • 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