Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Changing colours depending on variable's value

Hello everyone,

I got a problem with design. I want to change Text Object font colours dynamically:

This is how I've set expression in Calculated option field for three colours:

=IF($(vMarginDiff)<0 AND $(vMarginDiff)>=-3,

               RGB(251,219,36),

         IF($(vMarginDiff)>=0.0, RGB(131,165,61),RGB(210,29,19)))


This expression is not changing colours of font (only if I use IF statement without ELSE it works, but its not enought at all)

Variable is fine, it returns  the number of similar format like this 0,156946.

Can it be done like this or I just want too much?

here is the pic for better imagination (correct value of variable is in "Marže" box)

THANK YOU!

MP

1 Solution

Accepted Solutions
Not applicable
Author

Thx for an idea!

I have replaced the dot instead of comma with replace function so IF contition, works properly. Thank you very much!

=REPLACE(num(sum({<[Data.Typ položky]={"Deník"},[CSM strom-účty.Level3]={"Tržby zboží","Náklady                                         zboží"}>}Data.Částka/1000)/

                    ), '##'), ',' , '.' )

View solution in original post

6 Replies
Clever_Anjos
Employee
Employee

Whats the value of $(vMarginDiff)?

It returns 0,156946 with a coma?

Not applicable
Author

Thx for an idea!

I have replaced the dot instead of comma with replace function so IF contition, works properly. Thank you very much!

=REPLACE(num(sum({<[Data.Typ položky]={"Deník"},[CSM strom-účty.Level3]={"Tržby zboží","Náklady                                         zboží"}>}Data.Částka/1000)/

                    ), '##'), ',' , '.' )

Anonymous
Not applicable
Author

Hi Michal,

Make sure your font expression is like this

=IF ($(vMarginDiff)>=0.0, RGB (251,219,36), IF ($(vMarginDiff)<0 AND $(vMarginDiff)>=-3, RGB(131,165,61), RGB(210,29,19)))

Also i have attached a sample please refer that. Hope this helps you to solve your problem.

Regards,

Nandha

JoaquinLazaro
Partner - Specialist II
Partner - Specialist II

Hi Michal:

Have you tried IF ($vmarginDiff) >= 0 ....

Regards

Joaquín

Clever_Anjos
Employee
Employee

Would you mind giving me a "Helpful Answer"? Thanks in advance

Not applicable
Author

I think problem was in IF statement, where comma in nubmer was used as one of the conditions.

Ive had statement basically like:

IF(14,2545, RGB1, RGB2); co I could never reach else statement. When I used REPLACE and changed comma to dot, it worked.

But I dont get this behaviour at all...