Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
nam
Former Employee
Former Employee

Qlik Sense Calculating Variables in an 'IF' Statement

Hi Everyone, i have an If statement on the fly on a Qlik sense object

If(condition a=true, $(vVariable1),

     if(condition b=true, $(vVariable2),

          if(condition c=true, $(vVariable3),

                if(condition d=true, $(vVariable4),

                    if(.......................................................................))))...


Now naturally  all the variables 1-4 will evaluate first then the If conditions however what i want to do is only evaluate the variable if the condition is met first.. My actual script contains over 30 nested IF's and on each click on a filter evaluates all the variables and then the condition leading to extremely slow performance.


Has anyone identified a way to tackle this in a simple way

3 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

It is not the variable which is creating issue. It is the if statement which is giving you the performance issue.

You must use the different approach for your expression.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
duffman1968
Contributor III
Contributor III

Hey Naweed,

Have you considered taking care of more of these conditions in the data model? Say with more flags, or more of the combinations already predetermined?

When my interface conditional statements become overwhelming, I think push it back to the data model.

Good luck.

Regards,

Patrick

nam
Former Employee
Former Employee
Author

Hi Patrick

Yes i have, the purpose behind this is on the fly dynamic measures and dimension selection in a pivot table from data island list selection.

Yes the ideal way would be to remove the if statement and create a single table with changing expression, but im purposely trying to achieve everything in a single Pivot table. So here i basically want to somehow not calculate the variables until a condition is met on the fly to boost performance. what iv shown above is only a small snipped of the if statement each variable 1-4 has inner variables with complex calculation . Im trying to show the possibility of achieving this on the fly without the use of any extensions or plugins. The concept now works but its slow