Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
ishansjain2095
Creator
Creator

Error in expression: If takes 2-3 parameters

Hi,

I am a developer in Qlik Sense facing issue in an expression like:

 

=If(Condition <= 1 , Green(), Yellow(),
If(Condition <=20 , Yellow(), rgb(255,165,0),
If(Condition <=50 , rgb(255,165,0), Red())))

Need background colors like value less than or equal to 1 % show green color or else yellow() , value less than or equal to 20 %  show yellow() or else orange color and at last value less than or equal to 50% show orange color or else red() .

Please help me with this basic error. It would be helpful.

Regards

Ishan.

9 Replies
Kashyap_R
Partner - Specialist
Partner - Specialist

 

Hi

Try this

If(Condition <= 1 , green(),If(Condition <=20 , Yellow(), If(Condition <=50 , rgb(255,165,0), Red())))

Hope this helps 

Thanks

 

Thanks and Regards
Kashyap.R
MayilVahanan

Hi 

Try like below

 

If(Condition <= 0.01 , green(),If(Condition <=0.20 , Yellow(), If(Condition <=0.50 , rgb(255,165,0), Red())))

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
ishansjain2095
Creator
Creator
Author

Hi Kashyap,

Could you explain to me the if() statement in brief what it's doing?

ishansjain2095
Creator
Creator
Author

Hi Mayilvahanan,

Thanks for the query.

ishansjain2095
Creator
Creator
Author

Hi

Kashyap and Mayilvahanan I used both expressions in the background tab it showing the wrong background color as shown below.

Please help.

Kashyap_R
Partner - Specialist
Partner - Specialist

Hi 

Can u share the sample file and can u please elaborate on the requirement u need properly.

Thanks

Thanks and Regards
Kashyap.R
qlik4asif
Creator III
Creator III

=If(Condition <= 1 , Green(), Yellow(),
If(Condition <=20 , Yellow(), rgb(255,165,0),
If(Condition <=50 , rgb(255,165,0), Red())))

 

Sol: The If conditions are not correct

Eg: If condition value = 0.5

 It satisfies all the conditions(0.5 <=1 , 0.5<=20, 0.5<=50).

So the condition should be .

if Condition <=1 - Green, else

if >1 Condition <=20 - Yellow. else

if >20 Condition <=50 - rgb(255,165,0). else

Red.

=If(Condition <= 1 , Green(),

                  If(Condition > 1 And Condition <=20 , Yellow(),

                            If(Condition >20  And Condition <=50 , rgb(255,165,0), Red())))

 

 

 

ishansjain2095
Creator
Creator
Author

Hi QLik4asif,

Can this expression be used for comparing 5 different values?

qlik4asif
Creator III
Creator III

You can also use Pick Match function, which is having better performance than nested if statement