<?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 AGGR in Set Analysis Not Equivalent to IF Statement in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/AGGR-in-Set-Analysis-Not-Equivalent-to-IF-Statement/m-p/1931933#M76790</link>
    <description>&lt;P&gt;Hi - the following two expressions yield different results. I thought syntactically they are the same, but is there something different about how Qlik processes each of the two expressions below that could be causing different results?&lt;/P&gt;
&lt;P&gt;I don't think the data model is the culprit, as the first expression using IF generates correct results. The only reason I can think of is, &lt;EM&gt;AGGR within set analysis doesn't process the same way as AGGR in an IF statement&lt;/EM&gt;?&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Option #1 - AGGR in IF statement - correct result:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;sum({1} if(TranYr = CurrYr and placedt_all=aggr({1} nodistinct max({1}placedt_all),acctpol), -Payment))&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Option #2 - AGGR in set analysis - incorrect result (higher value than expected):&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;sum( {1 &amp;lt;TranYr = {$(=CurrYr)},&amp;nbsp;&lt;BR /&gt;placedt_all={"=max( aggr( {1} nodistinct max( {1} placedt_all),acctpol))"} &lt;BR /&gt;&amp;gt;} -Payment)&lt;/P&gt;</description>
    <pubDate>Tue, 17 May 2022 16:11:35 GMT</pubDate>
    <dc:creator>newuser</dc:creator>
    <dc:date>2022-05-17T16:11:35Z</dc:date>
    <item>
      <title>AGGR in Set Analysis Not Equivalent to IF Statement</title>
      <link>https://community.qlik.com/t5/App-Development/AGGR-in-Set-Analysis-Not-Equivalent-to-IF-Statement/m-p/1931933#M76790</link>
      <description>&lt;P&gt;Hi - the following two expressions yield different results. I thought syntactically they are the same, but is there something different about how Qlik processes each of the two expressions below that could be causing different results?&lt;/P&gt;
&lt;P&gt;I don't think the data model is the culprit, as the first expression using IF generates correct results. The only reason I can think of is, &lt;EM&gt;AGGR within set analysis doesn't process the same way as AGGR in an IF statement&lt;/EM&gt;?&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Option #1 - AGGR in IF statement - correct result:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;sum({1} if(TranYr = CurrYr and placedt_all=aggr({1} nodistinct max({1}placedt_all),acctpol), -Payment))&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Option #2 - AGGR in set analysis - incorrect result (higher value than expected):&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;sum( {1 &amp;lt;TranYr = {$(=CurrYr)},&amp;nbsp;&lt;BR /&gt;placedt_all={"=max( aggr( {1} nodistinct max( {1} placedt_all),acctpol))"} &lt;BR /&gt;&amp;gt;} -Payment)&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2022 16:11:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/AGGR-in-Set-Analysis-Not-Equivalent-to-IF-Statement/m-p/1931933#M76790</guid>
      <dc:creator>newuser</dc:creator>
      <dc:date>2022-05-17T16:11:35Z</dc:date>
    </item>
    <item>
      <title>Re: AGGR in Set Analysis Not Equivalent to IF Statement</title>
      <link>https://community.qlik.com/t5/App-Development/AGGR-in-Set-Analysis-Not-Equivalent-to-IF-Statement/m-p/1931957#M76791</link>
      <description>&lt;P&gt;In Option 1 ;&amp;nbsp; max(aggr( will return a different max placedt_all for each acctpol&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In Option 2 ;&amp;nbsp; Set is evaluated &lt;STRONG&gt;once for the entire chart&lt;/STRONG&gt; not for each acctpol&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2022 17:01:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/AGGR-in-Set-Analysis-Not-Equivalent-to-IF-Statement/m-p/1931957#M76791</guid>
      <dc:creator>vinieme12</dc:creator>
      <dc:date>2022-05-17T17:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: AGGR in Set Analysis Not Equivalent to IF Statement</title>
      <link>https://community.qlik.com/t5/App-Development/AGGR-in-Set-Analysis-Not-Equivalent-to-IF-Statement/m-p/1932060#M76799</link>
      <description>&lt;P&gt;Thank you - can you explain what you mean by "once for the entire chart"? Does that mean it doesn't select the max placedt_all for each acctpol but rather an overall max placedt_all?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2022 21:56:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/AGGR-in-Set-Analysis-Not-Equivalent-to-IF-Statement/m-p/1932060#M76799</guid>
      <dc:creator>newuser</dc:creator>
      <dc:date>2022-05-17T21:56:41Z</dc:date>
    </item>
    <item>
      <title>Re: AGGR in Set Analysis Not Equivalent to IF Statement</title>
      <link>https://community.qlik.com/t5/App-Development/AGGR-in-Set-Analysis-Not-Equivalent-to-IF-Statement/m-p/1932114#M76806</link>
      <description>&lt;P&gt;&lt;EM&gt;"Does that mean it doesn't select the max placedt_all for each acctpol but rather an overall max placedt_all? "&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Yes,&lt;/STRONG&gt; this is correct&lt;/P&gt;
&lt;P&gt;What's happening in your expression is since you are using aggr() and it can't return an array of values in SET Analysis this will just return NULL i.e&amp;nbsp;&lt;EM&gt;placedt_all&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/EM&gt;&amp;nbsp;={-}&amp;nbsp; &amp;nbsp; therefore this filter is never applied which is why you have higher values&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;can you explain what you mean by "once for the entire chart"?&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Set Analysis is not evaluated for each row/each dimension value, for example Max(SomeValue) in SET ANALYSIS will return the max value for the entire dataset not MAx for each dimension value&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2022 03:47:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/AGGR-in-Set-Analysis-Not-Equivalent-to-IF-Statement/m-p/1932114#M76806</guid>
      <dc:creator>vinieme12</dc:creator>
      <dc:date>2022-05-18T03:47:34Z</dc:date>
    </item>
  </channel>
</rss>

