<?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: sum of aggr() returns 0 in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/sum-of-aggr-returns-0/m-p/107839#M758679</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Although other parts of the expression was ignoring selection in current year, but TYPE was not... which is why the expression was not working. Ignored all selection for TYPE as well using Only({1} ... ) and it worked&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Aug 2018 19:44:05 GMT</pubDate>
    <dc:creator>sunny_talwar</dc:creator>
    <dc:date>2018-08-21T19:44:05Z</dc:date>
    <item>
      <title>sum of aggr() returns 0</title>
      <link>https://community.qlik.com/t5/QlikView/sum-of-aggr-returns-0/m-p/107834#M758674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have an expression which counts difference between beneficiaries for selected year and its previous year.The expression calculates the sum of beneficiaries for this year sum of beneficiaries for previous year and the subtracts both the values to get difference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;The part which calculates sum of beneficiaries for selected year gives correct value.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;But the part which calculates beneficiaries for previous year always evaluates to 0.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Part which calculates sum of beneficiaries for selected&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; &lt;STRONG&gt;&amp;nbsp; &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;sum({&amp;lt;Financial_Year = {'$(Selected_Year)'}, Quarter = {'$(Selected_Quarter)'}&amp;gt;} &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG style="font-size: 10pt;"&gt;aggr(if(TYPE = 'ABC',count({&amp;lt;Financial_Year = {'$(Selected_Year)'}, Quarter = {'$(Selected_Quarter)'}&amp;gt;}distinct BENEFICIARY))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Part which calculates sum of beneficiaries for previous year(which always evaluates to 0)&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;sum({&amp;lt;Financial_Year = {'$(Previous_Year)'}, Quarter = {'$(Selected_Quarter)'}&amp;gt;}&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;aggr(if(TYPE = 'ABC',count({&amp;lt;Financial_Year = {'$(Previous_Year)'}, Quarter = {'$(Selected_Quarter)'}&amp;gt;}distinct BENEFICIARY))&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have declared variables as follows&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Selected_Year = GetFieldSelections(Financial_Year)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Selected_Quarter = GetFieldSelections(Quarter)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Previous_Year = GetFieldSelections(Financial_Year) - 1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;My entire expression is as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;=if(GetFieldSelections(Quarter),&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;sum({&amp;lt;Financial_Year = {'$(Selected_Year)'}, Quarter = {'$(Selected_Quarter)'}&amp;gt;}&lt;SPAN style="font-size: 10pt;"&gt;aggr(if(TYPE = 'ABC',count({&amp;lt;Financial_Year = {'$(Selected_Year)'}, Quarter = {'$(Selected_Quarter)'}&amp;gt;}distinct BENEFICIARY)) -&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="font-size: 10pt;"&gt;sum({&amp;lt;Financial_Year = {'$(Previous_Year)'}, Quarter = {'$(Selected_Quarter)'}&amp;gt;}&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;aggr(if(TYPE = 'ABC',count({&amp;lt;Financial_Year = {'$(Previous_Year)'}, Quarter = {'$(Selected_Quarter)'}&amp;gt;}distinct BENEFICIARY)),&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;sum({&amp;lt;Financial_Year = {'$(Selected_Year)'}&amp;gt;}&lt;SPAN style="font-size: 10pt;"&gt;aggr(if(TYPE = 'ABC',count({&amp;lt;Financial_Year = {'$(Selected_Year)'}&amp;gt;}distinct BENEFICIARY)) -&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 10pt;"&gt;sum({&amp;lt;Financial_Year = {'$(Previous_Year)'}, Quarter = {'$(Selected_Quarter)'}&amp;gt;}&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;aggr(if(TYPE = 'ABC',count({&amp;lt;Financial_Year = {'$(Previous_Year)'}&amp;gt;}distinct BENEFICIARY))&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help will be appreciated &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/grin.png" /&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/sum-of-aggr-returns-0/m-p/107834#M758674</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: sum of aggr() returns 0</title>
      <link>https://community.qlik.com/t5/QlikView/sum-of-aggr-returns-0/m-p/107835#M758675</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this for previous year&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sum({&amp;lt;Financial_Year = {'$(Previous_Year)'}, Quarter = {'$(Selected_Quarter)'}&amp;gt;} Aggr(If(&lt;SPAN style="color: #ff0000;"&gt;Only({1} &lt;/SPAN&gt;TYPE&lt;SPAN style="color: #ff0000;"&gt;)&lt;/SPAN&gt; = 'ABC', Count({&amp;lt;Financial_Year = {'$(Previous_Year)'}, Quarter = {'$(Selected_Quarter)'}&amp;gt;} DISTINCT&amp;nbsp; BENEFICIARY))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you might be missing the last part of the expression where you give the Aggr's dimension/s&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Aug 2018 17:27:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/sum-of-aggr-returns-0/m-p/107835#M758675</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2018-08-21T17:27:37Z</dc:date>
    </item>
    <item>
      <title>Re: sum of aggr() returns 0</title>
      <link>https://community.qlik.com/t5/QlikView/sum-of-aggr-returns-0/m-p/107836#M758676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes I am sorry for that&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG style="font-style: inherit; font-size: 13.3333px; font-family: inherit;"&gt;sum({&amp;lt;Financial_Year = {'$(Selected_Year)'}, Quarter = {'$(Selected_Quarter)'}&amp;gt;} &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG style="font-size: 10pt; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;aggr(if(TYPE = 'ABC',count({&amp;lt;Financial_Year = {'$(Selected_Year)'}, Quarter = {'$(Selected_Quarter)'}&amp;gt;}distinct BENEFICIARY)), &lt;SPAN style="text-decoration: underline;"&gt;REFID))&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #3d3d3d; font-size: 10pt; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; text-decoration: underline;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #3d3d3d; font-size: 10pt; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; text-decoration: underline;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Added the dimension &lt;STRONG style="text-decoration: underline;"&gt;&lt;EM&gt;REFID&lt;/EM&gt;&lt;/STRONG&gt;&lt;STRONG style="color: #3d3d3d; font-size: 10pt; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; text-decoration: underline;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Aug 2018 18:19:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/sum-of-aggr-returns-0/m-p/107836#M758676</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-08-21T18:19:58Z</dc:date>
    </item>
    <item>
      <title>Re: sum of aggr() returns 0</title>
      <link>https://community.qlik.com/t5/QlikView/sum-of-aggr-returns-0/m-p/107837#M758677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Did you try it with the change I said?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sum({&amp;lt;Financial_Year = {'$(Previous_Year)'}, Quarter = {'$(Selected_Quarter)'}&amp;gt;} Aggr(If(&lt;SPAN style="color: #ff0000;"&gt;Only({1}&lt;/SPAN&gt; TYPE&lt;SPAN style="color: #ff0000;"&gt;)&lt;/SPAN&gt; = 'ABC', Count({&amp;lt;Financial_Year = {'$(Previous_Year)'}, Quarter = {'$(Selected_Quarter)'}&amp;gt;} DISTINCT&amp;nbsp; BENEFICIARY)), REFID))&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Aug 2018 18:27:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/sum-of-aggr-returns-0/m-p/107837#M758677</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2018-08-21T18:27:23Z</dc:date>
    </item>
    <item>
      <title>Re: sum of aggr() returns 0</title>
      <link>https://community.qlik.com/t5/QlikView/sum-of-aggr-returns-0/m-p/107838#M758678</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeah tried it just now and its working &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/grin.png" /&gt;.Can you please explain the effect of adding the part in red to the code&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Aug 2018 18:34:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/sum-of-aggr-returns-0/m-p/107838#M758678</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-08-21T18:34:55Z</dc:date>
    </item>
    <item>
      <title>Re: sum of aggr() returns 0</title>
      <link>https://community.qlik.com/t5/QlikView/sum-of-aggr-returns-0/m-p/107839#M758679</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Although other parts of the expression was ignoring selection in current year, but TYPE was not... which is why the expression was not working. Ignored all selection for TYPE as well using Only({1} ... ) and it worked&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Aug 2018 19:44:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/sum-of-aggr-returns-0/m-p/107839#M758679</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2018-08-21T19:44:05Z</dc:date>
    </item>
  </channel>
</rss>

