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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
greend21
Creator III
Creator III

Set analysis to avoid if's?

I have and expression like this:

IF(GetSelectedCount(SequenceInd)=0,

Count({$<RecOpenStatus = {'Open'}, SequenceInd = {'Seq'}>}DISTINCT ReceivableID),

    Count({$<RecOpenStatus = {'Open'}>}DISTINCT ReceivableID))

I don't think what I want to do is possible but I am hoping I am wrong and that I can increase performance. Is there another way to have my expression as Count({$<RecOpenStatus = {'Open'}, SequenceInd = {'Seq'}>}DISTINCT ReceivableID) but if another SequenceInd is selected, the result will reflect that? I am looking to reduce the IF statements in my application.

11 Replies
vishsaggi
Champion III
Champion III

Have not tested but may be you can try below and see

= Pick(GetSelectedCount(SequenceInd),

           Count({$<RecOpenStatus = {'Open'}, SequenceInd = {'Seq'}>}DISTINCT ReceivableID),

           Count({$<RecOpenStatus = {'Open'}>}DISTINCT ReceivableID))

marcus_sommer

Testing the UI (expressions) performance isn't very easy and without a systematically approach by evaluating the mem-files and/or looking within the document properties it's more a guessing than a monitoring. Nevertheless if there are not many objects so that the opening/calculating times might be added to noticable waiting-times the simpler approach of just using two objects/expressions and enabling either this one or the other will work to notice a significantly delaying or not.

A premise for it is to exclude any caching of the objects/calculations. This means you need to close QlikView after each test and by the test you shouldn't do anything else within the app as directly opening the sheet / activating the object / selecting one or maye a few values. Otherwise the caching could impact the results.

In your case I doubt that the if-approach is faster than the variable-suggestion from meggesto because the condition is calculated ones and applied to all rows meanwhile the condition in the if-approach will be calculated multiple times (for each row) and also the branches of the if are calculated for each row.

Therefore I suggest to use such a variable-approach whereby you don't need mandatory to create a "normal" variable else using an adhoc-variable will often work, too. This means something like:

Count({$<RecOpenStatus = {'Open'},

                SequenceInd *= {"$(=IF(GetSelectedCount(SequenceInd)=0, 'Seq', '*'))"}>} DISTINCT ReceivableID)

- Marcus