Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

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

If Condition in A Chart or Text Object!

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

4 Replies
Not applicable

If Condition in A Chart or Text Object!

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_michaelid
Honored Contributor II

If Condition in A Chart or Text Object!

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

If Condition in A Chart or Text Object!

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

Re: If Condition in A Chart or Text Object!

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

Community Browser