Skip to main content
The way to achieve your own success is the willingness to help somebody else. Go for it!
Showing results for 
Search instead for 
Did you mean: 
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),


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
Partner Ambassador/MVP
Partner Ambassador/MVP


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.


Kaushik Solanki

If reply is satisfactory, please "Like" the post.
If reply is solution, please mark as "Correct".
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.



Former Employee
Former Employee

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