<?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() and set analysis in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/aggr-and-set-analysis/m-p/1139607#M373669</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank You&lt;/P&gt;&lt;P&gt;This was very helpful, a concise explanation to confirm how the nesting works.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 30 May 2016 12:09:35 GMT</pubDate>
    <dc:creator>tomdabek</dc:creator>
    <dc:date>2016-05-30T12:09:35Z</dc:date>
    <item>
      <title>aggr() and set analysis</title>
      <link>https://community.qlik.com/t5/QlikView/aggr-and-set-analysis/m-p/1139605#M373667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to build a formula that will show me the total volume for products that were sold at a lower price this year than last year.&lt;/P&gt;&lt;P&gt;It seems aggr can be used to solve this but I am having difficulty understanding the sequence of the function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my statement below, what i think should happen&amp;nbsp; is that:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the aggregation first considered is the outer one - the first one in the formula that aggregates using the dimensions shown at the very end of the formula - AreaID, [Plant Number] and Material_Num&lt;/P&gt;&lt;P&gt;So i guess qlikview arranges the data in a temp table with those dimensions and then examines the if statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The next part i am not clear- in evaluating the if statement, i have another aggr() - is this even necessary?&amp;nbsp; It is aggregating by the same dimensions.&amp;nbsp; However it is necessary to examine this line by line within the original aggr function - i want to look at each combination of my dimensions (AreaID, [Plant Number] and Material_Num) to see if in each case the price is less than last year.&amp;nbsp; If true then the if statement should be evaluated - &lt;SPAN style="font-size: 13.3333px;"&gt;sum({&amp;lt;year = {$(=max(year))}&amp;gt;}Volume)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Finally, the very first part of the entire formula is sum(aggr(...&amp;nbsp; and this is telling the formula to add up all these instances where the price is down from the previous year.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum(aggr(&lt;/P&gt;&lt;P&gt;if(aggr(&lt;/P&gt;&lt;P&gt;sum({&amp;lt;year = {$(=max(year))}&amp;gt;}Revenue_Total)/sum({&amp;lt;year = {$(=max(year))}&amp;gt;}Volume),AreaID,[Plant Number]&lt;SPAN style="font-size: 13.3333px;"&gt;,CustomerID,&lt;/SPAN&gt;Material_Num) &amp;lt;&lt;/P&gt;&lt;P&gt;aggr(sum({&amp;lt;year = {$(=max(year)-1)}&amp;gt;}Revenue_Total)/sum({&amp;lt;year = {$(=max(year)-1)}&amp;gt;}Volume),AreaID,[Plant Number]&lt;SPAN style="font-size: 13.3333px;"&gt;,CustomerID,&lt;/SPAN&gt;Material_Num)&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;sum({&amp;lt;year = {$(=max(year))}&amp;gt;}Volume),0),AreaID,[Plant Number],CustomerID,Material_Num))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My questions are 1. Am I correctly understanding the logic and sequence of this?&lt;/P&gt;&lt;P&gt;2. The result is not correct (when i compare it to a more detailed listing that shows the dimensions of the aggr function above and each line is shown) - do i just have a formula error?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 May 2016 19:35:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/aggr-and-set-analysis/m-p/1139605#M373667</guid>
      <dc:creator>tomdabek</dc:creator>
      <dc:date>2016-05-24T19:35:01Z</dc:date>
    </item>
    <item>
      <title>Re: aggr() and set analysis</title>
      <link>https://community.qlik.com/t5/QlikView/aggr-and-set-analysis/m-p/1139606#M373668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think your basic understanding is correct.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have an advanced aggregation like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=&lt;EM&gt;OuterAggregation&lt;/EM&gt;( Aggr( &lt;EM&gt;InnerAggregation&lt;/EM&gt;, &lt;EM&gt;AggrDimensions&lt;/EM&gt;))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then Qlik will create a virtual, temporary table similar to a straight table, with &lt;EM&gt;AggrDimensions&lt;/EM&gt; as dimensions of that table and &lt;EM&gt;InnerAggregation&lt;/EM&gt; as the single expression.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Finally, this table will be projected on the outer chart dimensions and aggregated using the &lt;EM&gt;OuterAggregation.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With regard to your expression, I don't think you need the additional advanced aggregations in your &lt;EM&gt;InnerAggregation, &lt;/EM&gt;so this should be enough:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;sum(&amp;nbsp; //&lt;EM&gt;OuterAggregation&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; aggr(&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if( //&lt;EM&gt;InnerAggregation&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum({&amp;lt;year = {$(=max(year))}&amp;gt;} Revenue_Total) / sum({&amp;lt;year = {$(=max(year))}&amp;gt;} Volume)&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt; sum({&amp;lt;year = {$(=max(year)-1)}&amp;gt;}Revenue_Total)/sum({&amp;lt;year = {$(=max(year)-1)}&amp;gt;}Volume)&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum({&amp;lt;year = {$(=max(year))}&amp;gt;}Volume)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,0)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;,AreaID,[Plant Number],CustomerID,Material_Num) //&lt;EM&gt;AggrDimensions&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;If this is still not showing the correct values, we might need to look into the details of your expressions and data model.&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;To debug this kind of expression, I often do the same as you described, I create a straight table with the &lt;EM&gt;AggrDimensions&lt;/EM&gt; and the &lt;EM&gt;InnerAggregation, &lt;/EM&gt;in this case maybe using additional expressions to show each part of the &lt;EM&gt;InnerAggregation.&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;You might also want to have a look into&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;A href="https://community.qlik.com/qlik-blogpost/4418"&gt;Pitfalls of the Aggr function&lt;/A&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;and&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;A href="https://community.qlik.com/qlik-blogpost/4669"&gt;Set Analysis in the Aggr function&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 May 2016 22:58:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/aggr-and-set-analysis/m-p/1139606#M373668</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2016-05-24T22:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: aggr() and set analysis</title>
      <link>https://community.qlik.com/t5/QlikView/aggr-and-set-analysis/m-p/1139607#M373669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank You&lt;/P&gt;&lt;P&gt;This was very helpful, a concise explanation to confirm how the nesting works.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 May 2016 12:09:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/aggr-and-set-analysis/m-p/1139607#M373669</guid>
      <dc:creator>tomdabek</dc:creator>
      <dc:date>2016-05-30T12:09:35Z</dc:date>
    </item>
  </channel>
</rss>

