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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

If Condition in A Chart or Text Object!

Hi,

I am trying to use if condition in a straight table / text object to display images as follows:

(value<40%), display green color

(value>40%) and (value<70%), display yellow color

(value > 70%), display red color

The only problem is that it does not display red color, instead display only green and yellow color.

I have used the following expression. Probably it needs some modification. Can somebody please suggest?

=if((value<40),'qmem://<bundled>/BuiltIn/led_g.png',

         if((value>41)&(marks1<70),'qmem://<bundled>/BuiltIn/led_y.png',

              'qmem://<bundled>/BuiltIn/led_r.png')

)

Regards & Thanks,

- Khaled

1 Solution

Accepted Solutions
Not applicable
Author

Hi,

In your sample there are only marks1 70, 90, and 100

and since this is your requirements:

(value<40%), display green color

(value>40%) and (value<70%), display yellow color

(value > 70%), display red color

then your display will always be red^^

all you need to do is replace '&' from your expression to 'AND'

like this,

=if((value<40),'qmem://<bundled>/BuiltIn/led_g.png',

         if((value>39) and (marks1<70),'qmem://<bundled>/BuiltIn/led_y.png',

              'qmem://<bundled>/BuiltIn/led_r.png')

)

Regards,

Alex

View solution in original post

4 Replies
Not applicable
Author

Hi Khaled,

This expression is working  

=if((marks1<40),'qmem://<bundled>/BuiltIn/led_g.png',if(((marks1>=41)and marks1<=70)),'qmem://<bundled>/BuiltIn/led_y.png','qmem://<bundled>/BuiltIn/led_r.png'))

PLease try it and let me know

Thanks.

Sup

Jason_Michaelides
Partner - Master II
Partner - Master II

The "marks1>=41" part of this expression is not necessary.  IF() will stop at the first true condition, so if the "marks1<40" is false then it must be >=41...

=if((value<40),'qmem://<bundled>/BuiltIn/led_g.png',if((value<70),'qmem://<bundled>/BuiltIn/led_y.png','qmem://<bundled>/BuiltIn/led_r.png'))

Hope this helps,

Jason

Not applicable
Author

Hi,

In your sample there are only marks1 70, 90, and 100

and since this is your requirements:

(value<40%), display green color

(value>40%) and (value<70%), display yellow color

(value > 70%), display red color

then your display will always be red^^

all you need to do is replace '&' from your expression to 'AND'

like this,

=if((value<40),'qmem://<bundled>/BuiltIn/led_g.png',

         if((value>39) and (marks1<70),'qmem://<bundled>/BuiltIn/led_y.png',

              'qmem://<bundled>/BuiltIn/led_r.png')

)

Regards,

Alex

Not applicable
Author

Hi Supthigale,  Thank you for your response. 

Slightly modified the expression and it works fine now. Here it is:  =if((marks1<40),'qmem:///BuiltIn/led_g.png', if(((marks1>=40)and (marks1<=70)),'qmem:///BuiltIn/led_y.png', 'qmem:///BuiltIn/led_r.png')) 

Thanks,  - Khaled