0 Replies Latest reply: Mar 2, 2018 10:21 AM by George Menoutis RSS

    Performance choice for dynamic expressions

    George Menoutis

      I will be using code that might have slight syntactic errors, but I hope it will be sufficient to express my question.

       

      If in some expression I use SUM(fieldname*5+2), the formula inside the parenthesis must obviously be evaluated for each fieldname value.

      I guess this is the same in the case of SUM(if(fieldname<5,fieldname*3,fieldname/5)).

       

      However, a variable has a constant value throughout all the data. So, one question is if the following: Will

      SUM(if(varname<5,fieldnameA,fieldnameB))

      be evaluated for each A-B combination, or is qlikview smart enough to evaluate the if condition once and then replace it by whichever field the condition leads to?

       

      If the answer is "unfortunately, no", how about the following:

      SUM(&(varname))

      where in the script I have:

      set varname=if(varname<5,'fieldnameA','fieldnameB')

       

      Will this be evaluated once, as the formula text is not resolved from the start?

      I hope, and believe, this must be "yes", since else how would qv know for what data combinations it would have to evaluate the final expression?

       

      If I have been vague or there is any way to improve this post, please let me know and have a chance to make it right!