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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Using if else in expression

Hi

I would like to display different images(Smiley of colours red, orange and green, or blank image) based on the expression value in a straight table.  I have an expression labelled KPI_value and based on that value, i need to display the smiley as a second expression displayed as image. I am comparing the KPI_value to 2 target thresholds.  In terms of pseudo code, this is what I want to evaluate:

If threshold1 or threshold2 are null

     display blank image;

else if KPI_value<= threshold1

     display green smiley;

else if threshold1 < KPI_value <= threshold2

     display orange smiley;

else if  KPI_value > threshold2

     display red smiley;

else

     display blank image;

I would like to know how to write this if then else as an expression

Thanks in advance

Hasnaa

5 Replies
Not applicable
Author

Try this


if (isNull(threshold1) or isNull(threshold2),blank image,

     if(KPI_value<=threshold1,green smiley,

          if(KPI_value<=threshold2,orange smiley,

               if(KPI_value>threshold2,red smiley,blank image))))

Greetings,

Lucas

alexandros17
Partner - Champion III
Partner - Champion III

If (isnull(threshold1) or isnull(threshold2)

     "display blank image",

     if (KPI_value<= threshold1,

          "display green smiley"

          if (threshold1 < KPI_value and KPI_value <= threshold2,

               "display orange smiley;",

               if(  KPI_value > threshold2,

                    "display red smiley;",

                    "display blank image;"

               )

          )

     )

)

Hope it helps

Anonymous
Not applicable
Author

Here is the example expression,  Hope it helps.

=if([Net Margin] > 0, 'qmem://<bundled>/BuiltIn/smiley3_y.png', if([Net Margin] < 0, 'qmem://<bundled>/BuiltIn/smiley3_r.png',

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

Anonymous
Not applicable
Author

Hi.

Thanks all. It works

Regards

Hasnaa

Not applicable
Author

Great!

Make sure you mark this discussion as answered though!

Cheers,

Lucas