Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
BI & Data Trends 2021. Discover the top 10 trends emerging in today. Join us on Dec. 8th REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
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.

Labels (1)
9 Replies
Highlighted
Partner
Partner

 

Hi

Try this

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

Hope this helps 

Thanks

 

Highlighted

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
Highlighted
Creator
Creator

Hi Kashyap,

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

Highlighted
Creator
Creator

Hi Mayilvahanan,

Thanks for the query.

Highlighted
Creator
Creator

Hi

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

Please help.

Highlighted
Partner
Partner

Hi 

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

Thanks

Highlighted
Creator II
Creator II

=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())))

 

 

 

Highlighted
Creator
Creator

Hi QLik4asif,

Can this expression be used for comparing 5 different values?

Highlighted
Creator II
Creator II

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