# Qlik Sense App Development

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

Regards

Ishan.

Labels (1)
• ### Qlik Sense

9 Replies
Highlighted 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 MVP

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

Hi Kashyap,

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

Highlighted Creator

Hi Mayilvahanan,

Thanks for the query.

Highlighted Creator

Hi

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

Highlighted Partner

Hi

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

Thanks

Highlighted 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

Hi QLik4asif,

Can this expression be used for comparing 5 different values?

Highlighted Creator II

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