<?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 choice for dynamic expressions in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Performance-choice-for-dynamic-expressions/m-p/42259#M2856</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi !&lt;/P&gt;&lt;P&gt;My answer is Yes.&lt;/P&gt;&lt;P&gt;Qlik evaluates IF condition for every record in table field without analysis what you coded and what you want to do &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;.&lt;/P&gt;&lt;P&gt;Using IF condition check in measures is very expensive in terms of performance.&lt;/P&gt;&lt;P&gt;And your decision Sum($(varname)) is right BUT never forget one important thing:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;/!&lt;/SPAN&gt;&lt;SPAN style="text-decoration: underline;"&gt;\&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt;"&gt;Use '=' in variable before expression if want to calculate it first, before variable expanded:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;let varname = '=if(varname&amp;lt;5,[fieldnameA],[fieldnameB])' ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Using var without '=' works same as &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;SUM(if(varname&amp;lt;5,fieldnameA,fieldnameB)) and no performance advantage.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Reference:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.qlik.com/en-US/sense/November2017/Subsystems/Hub/Content/Scripting/work-with-variables-in-data-load-editor.htm#anchor-5" title="https://help.qlik.com/en-US/sense/November2017/Subsystems/Hub/Content/Scripting/work-with-variables-in-data-load-editor.htm#anchor-5"&gt;https://help.qlik.com/en-US/sense/November2017/Subsystems/Hub/Content/Scripting/work-with-variables-in-data-load-editor.…&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 15 Oct 2018 08:42:04 GMT</pubDate>
    <dc:creator>Zhandos_Shotan</dc:creator>
    <dc:date>2018-10-15T08:42:04Z</dc:date>
    <item>
      <title>Performance choice for dynamic expressions</title>
      <link>https://community.qlik.com/t5/App-Development/Performance-choice-for-dynamic-expressions/m-p/42258#M2855</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I will be using code that might have slight syntactic errors, but I hope it will be sufficient to express my question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&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;/P&gt;&lt;P&gt;I guess this is the same in the case of SUM(if(fieldname&amp;lt;5,fieldname*3,fieldname/5)).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, a variable has a constant value throughout all the data. So, one question is if the following: Will&lt;/P&gt;&lt;P&gt;SUM(if(varname&amp;lt;5,fieldnameA,fieldnameB))&lt;/P&gt;&lt;P&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;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the answer is "unfortunately, no", how about the following:&lt;/P&gt;&lt;P&gt;SUM(&amp;amp;(varname))&lt;/P&gt;&lt;P&gt;where in the script I have:&lt;/P&gt;&lt;P&gt;set varname=if(varname&amp;lt;5,'fieldnameA','fieldnameB')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Will this be evaluated once, as the formula text is not resolved from the start?&lt;/P&gt;&lt;P&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;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&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;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Nov 2024 08:36:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Performance-choice-for-dynamic-expressions/m-p/42258#M2855</guid>
      <dc:creator>gmenoutis</dc:creator>
      <dc:date>2024-11-16T08:36:53Z</dc:date>
    </item>
    <item>
      <title>Re: Performance choice for dynamic expressions</title>
      <link>https://community.qlik.com/t5/App-Development/Performance-choice-for-dynamic-expressions/m-p/42259#M2856</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi !&lt;/P&gt;&lt;P&gt;My answer is Yes.&lt;/P&gt;&lt;P&gt;Qlik evaluates IF condition for every record in table field without analysis what you coded and what you want to do &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;.&lt;/P&gt;&lt;P&gt;Using IF condition check in measures is very expensive in terms of performance.&lt;/P&gt;&lt;P&gt;And your decision Sum($(varname)) is right BUT never forget one important thing:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;/!&lt;/SPAN&gt;&lt;SPAN style="text-decoration: underline;"&gt;\&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt;"&gt;Use '=' in variable before expression if want to calculate it first, before variable expanded:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;let varname = '=if(varname&amp;lt;5,[fieldnameA],[fieldnameB])' ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Using var without '=' works same as &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;SUM(if(varname&amp;lt;5,fieldnameA,fieldnameB)) and no performance advantage.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Reference:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.qlik.com/en-US/sense/November2017/Subsystems/Hub/Content/Scripting/work-with-variables-in-data-load-editor.htm#anchor-5" title="https://help.qlik.com/en-US/sense/November2017/Subsystems/Hub/Content/Scripting/work-with-variables-in-data-load-editor.htm#anchor-5"&gt;https://help.qlik.com/en-US/sense/November2017/Subsystems/Hub/Content/Scripting/work-with-variables-in-data-load-editor.…&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Oct 2018 08:42:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Performance-choice-for-dynamic-expressions/m-p/42259#M2856</guid>
      <dc:creator>Zhandos_Shotan</dc:creator>
      <dc:date>2018-10-15T08:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: Performance choice for dynamic expressions</title>
      <link>https://community.qlik.com/t5/App-Development/Performance-choice-for-dynamic-expressions/m-p/42260#M2857</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It depends on your datamodel which way leads to the right results in the most performing way. If possible try to avoid constructs like: sum(if(condition, FIELD)) and replace it with: if(condition, sum(FIELD)) or even better with set analysis: sum({&amp;lt; FIELD = {'Condition'}&amp;gt;} FIELD) - see: &lt;A href="https://community.qlik.com/qlik-blogpost/4076"&gt;A Primer on Set Analysis&lt;/A&gt;. The use of variables won't speed up any calculation because it is just a replacement of expression-text which will be evaluated before the calculations takes place.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Oct 2018 08:18:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Performance-choice-for-dynamic-expressions/m-p/42260#M2857</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2018-10-16T08:18:26Z</dc:date>
    </item>
    <item>
      <title>Re: Performance choice for dynamic expressions</title>
      <link>https://community.qlik.com/t5/App-Development/Performance-choice-for-dynamic-expressions/m-p/42261#M2858</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Marcus, your last sentence doesn't make sense to me - do you maybe intend to say "the use of variables won't &lt;SPAN style="text-decoration: underline;"&gt;slow down&lt;/SPAN&gt; the calculation because...."?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Oct 2018 06:11:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Performance-choice-for-dynamic-expressions/m-p/42261#M2858</guid>
      <dc:creator>gmenoutis</dc:creator>
      <dc:date>2018-10-19T06:11:56Z</dc:date>
    </item>
    <item>
      <title>Re: Performance choice for dynamic expressions</title>
      <link>https://community.qlik.com/t5/App-Development/Performance-choice-for-dynamic-expressions/m-p/42262#M2859</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A variable is just a replacement for anything else. This means it depends of the content of the variable if a calculation is fast/slow and correct or not. A bad and slow expression within a variable is just this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Oct 2018 06:30:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Performance-choice-for-dynamic-expressions/m-p/42262#M2859</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2018-10-19T06:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: Performance choice for dynamic expressions</title>
      <link>https://community.qlik.com/t5/App-Development/Performance-choice-for-dynamic-expressions/m-p/42263#M2860</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I do not want to dispute with Legend rank community member &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;. But if variable is just replacement, i need explanation why example below works and how it works?&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Fragment from qlik.help reference from my first reply:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Let vSales = 'Sum(Sales)' ;&lt;/P&gt;&lt;P&gt;Let &lt;SPAN style="color: #3366ff;"&gt;vSales2&lt;/SPAN&gt; = '&lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #ff0000;"&gt;Sum(Sales)&lt;/STRONG&gt;';&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0f0f0f; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; font-size: 12px; background-color: #fafafa;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE cellspacing="0" class="TableStyle-tableGrid" data-mc-conditions="Targets.NotToTranslate" style="margin-bottom: 15px; color: #0f0f0f; font-family: 'Open Sans', Arial, sans-serif; font-size: 14px; margin-right: auto;"&gt;&lt;TBODY style="border-top-width: 2px; border-top-color: #0f0f0f;"&gt;&lt;TR style="border-bottom-width: 1px; border-bottom-color: #d5d5d5;"&gt;&lt;TD class="BodyI--" style="padding: 7px; border: 1px solid #d5d5d5;"&gt;Dim&lt;/TD&gt;&lt;TD class="BodyI--" style="padding: 7px; border: 1px solid #d5d5d5;"&gt;$(vSales)&lt;/TD&gt;&lt;TD class="BodyG--" style="padding: 7px; border: 1px solid #d5d5d5;"&gt;$(&lt;SPAN style="color: #3366ff;"&gt;vSales2&lt;/SPAN&gt;)&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border-bottom-width: 1px; border-bottom-color: #d5d5d5;"&gt;&lt;TD class="BodyI--" style="padding: 7px; border: 1px solid #d5d5d5;"&gt;A&lt;/TD&gt;&lt;TD class="BodyI--" style="padding: 7px; border: 1px solid #d5d5d5;"&gt;350&lt;/TD&gt;&lt;TD class="BodyG--" style="padding: 7px; border: 1px solid #d5d5d5;"&gt;1560&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border-bottom-width: 1px; border-bottom-color: #d5d5d5;"&gt;&lt;TD class="BodyI--" style="padding: 7px; border: 1px solid #d5d5d5;"&gt;B&lt;/TD&gt;&lt;TD class="BodyI--" style="padding: 7px; border: 1px solid #d5d5d5;"&gt;470&lt;/TD&gt;&lt;TD class="BodyG--" style="padding: 7px; border: 1px solid #d5d5d5;"&gt;1560&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border-bottom-width: 1px; border-bottom-color: #d5d5d5;"&gt;&lt;TD class="BodyC--" style="padding: 7px; border: 1px solid #d5d5d5;"&gt;C&lt;/TD&gt;&lt;TD class="BodyC--" style="padding: 7px; border: 1px solid #d5d5d5;"&gt;740&lt;/TD&gt;&lt;TD class="BodyA--" style="padding: 7px; border: 1px solid #d5d5d5;"&gt;1560&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Why vSales2 = 1560 for each row if its not 'Sum(&lt;STRONG&gt;total&lt;/STRONG&gt; Sales)' ?&lt;/P&gt;&lt;P&gt;Also i did optimisations with some complex, messy expression whith multi level if conditions. Turn it into one row expression with precalculated multi level variables and it finally works several times faster.&lt;/P&gt;&lt;P&gt;May be i misunderstand something...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Oct 2018 11:44:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Performance-choice-for-dynamic-expressions/m-p/42263#M2860</guid>
      <dc:creator>Zhandos_Shotan</dc:creator>
      <dc:date>2018-10-19T11:44:08Z</dc:date>
    </item>
    <item>
      <title>Re: Performance choice for dynamic expressions</title>
      <link>https://community.qlik.com/t5/App-Development/Performance-choice-for-dynamic-expressions/m-p/42264#M2861</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's just a question to when the evaluation of the variable happens. By a variable with a starting equal sign the evaluation happens immediately and only the result of them is assigned to the variable and without equal sign the content will be evaluated on the place where it is used and during this run-time. It's much better explained here: &lt;A href="https://community.qlik.com/qlik-blogpost/3996"&gt;The Little Equals Sign&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 20 Oct 2018 09:11:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Performance-choice-for-dynamic-expressions/m-p/42264#M2861</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2018-10-20T09:11:15Z</dc:date>
    </item>
  </channel>
</rss>

