Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

nested If statements (performance issue)

Hi All,

     i'm working with nested if condition like

= if( value= 0 or len(value)=0, Black(),
if ( value > 0 and value <=.35, rgb(240,0,0),
if (value>=.50, Green(),
rgb(227,187,28)
)))

is there a way i can write the same expression using pick and mactch function

i'm having some performance issues with my application reason is---- there are so many nested if statements

any suggestions of tweaks in expression for better performance help

6 Replies
manas_bn
Creator
Creator

If the same expression is used in multiple places, i.e., if the range for "value" is same in many expressions, you could create a flag on the scripting side (using intervalmatch may be) and use the flag in the if condition.

I could be wrong but a numeric flag might help improve performance instead of checking for this condition...

Anonymous
Not applicable
Author

Thanks for the reply Manas, the value here is just Sum(inventory).........no scope for creating a flag

Regards

Sri

Anonymous
Not applicable
Author

any sugesstions

CELAMBARASAN
Partner - Champion
Partner - Champion

I can optimize something like

= if( Alt(value, 0) = 0, Black(),
if (value <=.35, rgb(240,0,0),
if (value>=.50, Green(),
rgb(227,187,28)
)))

Anonymous
Not applicable
Author

Thanks for the reply ..but the expression still has 3 if condition i want them to be reduced............ because all my objects have multiple if conditions .....

so this just a sample expression

here is my intial post

http://community.qlik.com/message/392820#392820

Thanks agian

Sri

Anonymous
Not applicable
Author

Hi, Sri,

I think match can not use expression as a parameter.

And nested if conditions can only effect the time consuming when change selections but not the performance if the logic is correct.  But of course nested if can easily cause performance issue.

The if expression in your post can not be optimized further, but you can try some improvement for the whole dash:

1. Create some new fields for some if cases in the load script, which actually can make the calculation fast than using if in the dash.

2. Use SET variable for some if expressions which gonna be reused.

Hope this helps

Zhihong