Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
davyqliks
Specialist
Specialist

Adding to the colour section of expression

Hi All,

I hope you can help..

I previously had a colour if statement where i couloured the text based on a set parameter like below:

if(Today()-90<= Only( [Last Order Date UK]),
RGB(0,0,0),

if(Today()-90>= Only( [Last Order Date UK]),
rgb(255,26,26),

)
)

 

This is working well but i have found it does not cover the required so i have had to change the logic.

I have created a flag on load to identify the following;

if([3M Shipped QTY]=0,True(),False() )as [No 3 Month Stock] ,

I now need to apply set analysis colour where '-1' = rgb(255,26,26), and '0' = RGB(0,0,0),

This is my effort but i have isues on brackets (where i have added space around them) 

if   (   Only   (    {<[No 3 Month Stock]={'0'}>},RGB(0,0,0),

if(only({<[No 3 Month Stock]={'-1'}>},RGB(255,26,26)
)
)

 

PLease can you let me know how i would write an if for colouring text for this given variable.

Thank you in advance.

Daniel

Labels (2)
1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

You don't want to use set analysis for this as you want to test row-by-row. So:

if ([No 3 Month Stock], RGB(255,26,26), RGB(0,0,0))

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

View solution in original post

3 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

You don't want to use set analysis for this as you want to test row-by-row. So:

if ([No 3 Month Stock], RGB(255,26,26), RGB(0,0,0))

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

davyqliks
Specialist
Specialist
Author

Hi,

Thank you for the reply. I will try this but also had some success with the following in the text colour box:

I was using set as the flag is a true false.

if(Only({<[No 3 Month Stock]={'-1'}>}[No 3 Month Stock]),RGB(255,26,26))

 

Thank you for taking the time to reply though, much appreciated and i will credit it as success.

Thanks

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

The set expression works but is more code than necessary.  Let's break it down. 

In Qlik, "0" or null is False. All other values are True. Given that [No 3 Month Stock] has values of 0 or -1, my expression resolves to:

if (-1, RGB(255,26,26), RGB(0,0,0))

or

if (0, RGB(255,26,26), RGB(0,0,0))

Your form is a bit more complicated.

Only({<[No 3 Month Stock]={'-1'}>}[No 3 Month Stock])

returns -1 if the value is -1, otherwise it returns null. So after the "Only(...)" your expression resolves to:

if (-1, RGB(255,26,26), RGB(0,0,0))

or 

if (null, RGB(255,26,26), RGB(0,0,0))

Same thing, but I think yours is more complex than necessary.

-Rob