<?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: AGGR function in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/AGGR-function/m-p/939268#M324088</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you see if adding NODISTINCT helps:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="color: #575757; font-style: inherit; font-size: 10.6667px; font-family: inherit; font-weight: inherit;"&gt;&lt;STRONG style=": ; font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;Sum&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"&gt;&lt;STRONG style="color: #575757;"&gt; (&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"&gt;&lt;STRONG style="color: #575757;"&gt;AGGR(&lt;SPAN style="color: #ff0000;"&gt;NODISTINCT&lt;/SPAN&gt;&lt;BR /&gt;//If Volume movement is zero (allows the manual postings to calculate)&lt;BR /&gt;(If(((Sum({$&amp;lt;Scenario = {Actual}&amp;gt;}ValueInKG)/1000-sum(ValueInKG)/1000)=0),&lt;BR /&gt;&lt;BR /&gt;//0 - all rate&lt;BR /&gt;0,&lt;BR /&gt;&lt;BR /&gt;//If scenario volume is 0&lt;BR /&gt;(if(sum(ValueInKG) = 0,&lt;BR /&gt;&lt;BR /&gt;//Then Net Revenue Actual&lt;BR /&gt;sum({$&amp;lt; Scenario={Actual}&amp;gt;}NetRevenue),&lt;BR /&gt;&lt;BR /&gt;//Else Net Rev/T (Scenario) * Volume Movement (Actual - Scenario)&lt;BR /&gt;(sum(NetRevenue)/(sum(ValueInKG)/1000))* ((Sum({$&amp;lt;Scenario = {Actual}&amp;gt;}ValueInKG)/1000)-(sum(ValueInKG)/1000))))))&lt;BR /&gt;,StatementAccountNumber,PartNumber&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #575757; font-size: 8pt; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;STRONG style=": ; font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;))&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 21 Oct 2015 15:40:17 GMT</pubDate>
    <dc:creator>sunny_talwar</dc:creator>
    <dc:date>2015-10-21T15:40:17Z</dc:date>
    <item>
      <title>AGGR function</title>
      <link>https://community.qlik.com/t5/QlikView/AGGR-function/m-p/939267#M324087</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;I have a volume variance calculation which is calculating at the lowest level of detail for my report (PartNumber and StatementAccountNumber) combination.&amp;nbsp; The issue that I have is related to when you want to total a column on a pivot table, in that I need a total to be returned which is the sum of the lowest level of detail NOT the expression working over the totals of the detail.&amp;nbsp; I believe that to resolve this you use the following formula:&lt;/P&gt;&lt;P&gt;Sum(AGGR( &lt;EM&gt;Formula ),&lt;/EM&gt;Dim1,Dim2&lt;EM&gt;))&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;For me this formula looks as below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;SPAN style="color: #0000ff;"&gt;Sum&lt;/SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;AGGR&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-size: 8pt;"&gt;//If Volume movement is zero (allows the manual postings to calculate)&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;If&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(((&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;({$&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Scenario&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; = {Actual}&amp;gt;}&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;ValueInKG&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)/1000-&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;ValueInKG&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)/1000)=0),&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-size: 8pt;"&gt;//0 - all rate&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;0,&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-size: 8pt;"&gt;//If scenario volume is 0&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;ValueInKG&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;) = 0,&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-size: 8pt;"&gt;//Then Net Revenue Actual&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;({$&amp;lt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Scenario&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;={Actual}&amp;gt;}&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;NetRevenue&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;),&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-size: 8pt;"&gt;//Else Net Rev/T (Scenario) * Volume Movement (Actual - Scenario)&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;NetRevenue&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)/(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;ValueInKG&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)/1000))* ((&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;({$&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Scenario&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; = {Actual}&amp;gt;}&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;ValueInKG&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)/1000)-(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;ValueInKG&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)/1000))))))&lt;BR /&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;StatementAccountNumber&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;PartNumber&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;If I use this formula then it calculates perfectly for some items but returns zero for others (If I look at what is calculating at the lowest level) hence it returns an incorrect total. I believe that this is related to the "Scenario" field in my formula (three scenarios exist - Actual is the main comparitor versus the other scenarios of Budget and Last Year).&amp;nbsp; The formula will calculate correctly for items where the scenario that has been selected contains data (i.e. budget or last year), however, if it doesn't contain data, but the same PartNumberStatementAccount combination has data for the&amp;nbsp; Actual scenario it returns blank (instead of the volume variance).&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Does the AGGR field need a scenario setting for it?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Oct 2015 14:23:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/AGGR-function/m-p/939267#M324087</guid>
      <dc:creator />
      <dc:date>2015-10-21T14:23:53Z</dc:date>
    </item>
    <item>
      <title>Re: AGGR function</title>
      <link>https://community.qlik.com/t5/QlikView/AGGR-function/m-p/939268#M324088</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you see if adding NODISTINCT helps:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="color: #575757; font-style: inherit; font-size: 10.6667px; font-family: inherit; font-weight: inherit;"&gt;&lt;STRONG style=": ; font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;Sum&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"&gt;&lt;STRONG style="color: #575757;"&gt; (&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"&gt;&lt;STRONG style="color: #575757;"&gt;AGGR(&lt;SPAN style="color: #ff0000;"&gt;NODISTINCT&lt;/SPAN&gt;&lt;BR /&gt;//If Volume movement is zero (allows the manual postings to calculate)&lt;BR /&gt;(If(((Sum({$&amp;lt;Scenario = {Actual}&amp;gt;}ValueInKG)/1000-sum(ValueInKG)/1000)=0),&lt;BR /&gt;&lt;BR /&gt;//0 - all rate&lt;BR /&gt;0,&lt;BR /&gt;&lt;BR /&gt;//If scenario volume is 0&lt;BR /&gt;(if(sum(ValueInKG) = 0,&lt;BR /&gt;&lt;BR /&gt;//Then Net Revenue Actual&lt;BR /&gt;sum({$&amp;lt; Scenario={Actual}&amp;gt;}NetRevenue),&lt;BR /&gt;&lt;BR /&gt;//Else Net Rev/T (Scenario) * Volume Movement (Actual - Scenario)&lt;BR /&gt;(sum(NetRevenue)/(sum(ValueInKG)/1000))* ((Sum({$&amp;lt;Scenario = {Actual}&amp;gt;}ValueInKG)/1000)-(sum(ValueInKG)/1000))))))&lt;BR /&gt;,StatementAccountNumber,PartNumber&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #575757; font-size: 8pt; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;STRONG style=": ; font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;))&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Oct 2015 15:40:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/AGGR-function/m-p/939268#M324088</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2015-10-21T15:40:17Z</dc:date>
    </item>
    <item>
      <title>Re: AGGR function</title>
      <link>https://community.qlik.com/t5/QlikView/AGGR-function/m-p/939269#M324089</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for your response Sunny.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately it hasn't made any difference and is returning exactly the same as it would without it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Oct 2015 15:50:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/AGGR-function/m-p/939269#M324089</guid>
      <dc:creator />
      <dc:date>2015-10-21T15:50:45Z</dc:date>
    </item>
  </channel>
</rss>

