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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Expression optimization

Hello everyone

I'm  trying to optimize this expression

if (PER=0,
      IF(IND=0,sum(Value*coef),

           sum(Value*IND*coef)),

                     IF(IND=0,sum(Value*coef*PER),

                                    sum(Value*IND*coef*PER))) 

the thing is it depends on the users selection so can't optimize it in the script, and at the same time pick (match) doesn't work because for example PER can aither be 0 or (0 or 1).same for IND.

Any idea can be helpful,

Thanks in advance

15 Replies
Not applicable
Author

Firt of all Thank you for your answer, It doesn't work because as I said before it depends on the user's selection, so this way won't get the needed result

Not applicable
Author

Thank you the substringcount() is definitly interesting , but In terms of performance  for multi million rows it says it didn't change that much from nested IF.

Not applicable
Author

I was wondering if we can do  something like this ,pick(match (IND,0,sum(IND)>=1)

martynlloyd
Partner - Creator III
Partner - Creator III

I could explain how to use selected values, but as Rob says, if the values of PER and IND are only 0 or 1 then the outcome of your expressions will ALWAYS equal Value*coef
Maybe you could explain with some sample data (numbers)?

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

It seems to me that

sum(Value*coef)

will give you the same answer as the if() statement.

-Rob

Not applicable
Author

I will try to create a sample application and put it on this forum , since the data model is quite complex, that will help you understand the motivation behind my question.

Thank you for taking time to answer my question