<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Performance: if() vs variable fieldname in expression in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Performance-if-vs-variable-fieldname-in-expression/m-p/56760#M783918</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not full sure I understand where you are using this, but AFAIK anytime you use an if statement (through a variable or directly) it will be evaluated on row by row basis and it will evaluate both the true and false condition before it displays the output for either of the condition. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 06 Mar 2018 09:58:06 GMT</pubDate>
    <dc:creator>sunny_talwar</dc:creator>
    <dc:date>2018-03-06T09:58:06Z</dc:date>
    <item>
      <title>Performance: if() vs variable fieldname in expression</title>
      <link>https://community.qlik.com/t5/QlikView/Performance-if-vs-variable-fieldname-in-expression/m-p/56759#M783917</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;I will be using code that might have slight syntactic errors, but I hope it will be sufficient to express my question.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;If in some expression I use SUM(fieldname*5+2), the formula inside the parenthesis must obviously be evaluated for each fieldname value.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;I guess this is the same in the case of SUM(if(fieldname&amp;lt;5,fieldname*3,fieldname/5)).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;However, a variable has a constant value throughout all the data. So, one question is if the following: Will&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;SUM(if(varname&amp;lt;5,fieldnameA,fieldnameB))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;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?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;If the answer is "unfortunately, no", how about the following:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;SUM(&amp;amp;(varname))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;where in the script I have:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;set varname=if(varname&amp;lt;5,'fieldnameA','fieldnameB')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Will this be evaluated once, as the formula text is not resolved from the start?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;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?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;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!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Performance-if-vs-variable-fieldname-in-expression/m-p/56759#M783917</guid>
      <dc:creator>gmenoutis</dc:creator>
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Performance: if() vs variable fieldname in expression</title>
      <link>https://community.qlik.com/t5/QlikView/Performance-if-vs-variable-fieldname-in-expression/m-p/56760#M783918</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not full sure I understand where you are using this, but AFAIK anytime you use an if statement (through a variable or directly) it will be evaluated on row by row basis and it will evaluate both the true and false condition before it displays the output for either of the condition. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Mar 2018 09:58:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Performance-if-vs-variable-fieldname-in-expression/m-p/56760#M783918</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2018-03-06T09:58:06Z</dc:date>
    </item>
    <item>
      <title>Re: Performance: if() vs variable fieldname in expression</title>
      <link>https://community.qlik.com/t5/QlikView/Performance-if-vs-variable-fieldname-in-expression/m-p/56761#M783919</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The variable evaluation might not happen row-wise (based on it's definition), however, the check of TRUE/FALSE in IF clause would get evaluated row-wise. Instead, for such case the below structure would be a winner may be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If( variable&amp;lt;5, Sum(FieldA), Sum(FieldB))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or, may be like second way you have shown.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Mar 2018 10:09:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Performance-if-vs-variable-fieldname-in-expression/m-p/56761#M783919</guid>
      <dc:creator>tresB</dc:creator>
      <dc:date>2018-03-06T10:09:28Z</dc:date>
    </item>
  </channel>
</rss>

