<?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 How Aggr() handles selection with set modifier in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/How-Aggr-handles-selection-with-set-modifier/m-p/1388678#M819542</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I am trying to understand the behaviour or current selections on Aggr(). For example I have the following data set:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD * INLINE [&lt;/P&gt;&lt;P&gt;Test, Target, SessionNum, Student&lt;/P&gt;&lt;P&gt;A, 10, 1, John&lt;/P&gt;&lt;P&gt;A, 10, 2, Mark&lt;/P&gt;&lt;P&gt;A, 10, 3, Mark&lt;/P&gt;&lt;P&gt;B, 58, 1, John&lt;/P&gt;&lt;P&gt;B, 58, 2, Kelly&lt;/P&gt;&lt;P&gt;C, 123, 1, Mark&lt;/P&gt;&lt;P&gt;D, 77, 1, Mark&lt;/P&gt;&lt;P&gt;D, 77, 2, John&lt;/P&gt;&lt;P&gt;D, 77, 3, John&lt;/P&gt;&lt;P&gt;D, 77, 4, Kelly&lt;/P&gt;&lt;P&gt;D, 77, 5, John&lt;/P&gt;&lt;P&gt;E, 947, 1, John&lt;/P&gt;&lt;P&gt;E, 947, 2, Kelly&lt;/P&gt;&lt;P&gt;F, 3, 1, Kelly&lt;/P&gt;&lt;P&gt;];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I created a straight table with the following:&lt;/P&gt;&lt;P&gt;Dimension: [Student]&lt;/P&gt;&lt;P&gt;Expression: Sum({1} Aggr(Avg([Target]), [Test]))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The result is:&lt;/P&gt;&lt;P&gt;John | 1015&lt;/P&gt;&lt;P&gt;Kelly | 3&lt;/P&gt;&lt;P&gt;Mark | 200&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can understand how these numbers come about. But when I select just one Student, "Mark", the result becomes this:&lt;/P&gt;&lt;P&gt;John | 10&lt;/P&gt;&lt;P&gt;Mark | 200&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And I can't quite understand why this is so. Is it that QlikView will first look at what Tests that are filtered according to my Student selection (A, C, and D), and then go back to the original data set and pick only these Tests and pass them to the Aggr() function?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
    <dc:creator />
    <dc:date>2020-11-25T16:16:04Z</dc:date>
    <item>
      <title>How Aggr() handles selection with set modifier</title>
      <link>https://community.qlik.com/t5/QlikView/How-Aggr-handles-selection-with-set-modifier/m-p/1388678#M819542</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I am trying to understand the behaviour or current selections on Aggr(). For example I have the following data set:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD * INLINE [&lt;/P&gt;&lt;P&gt;Test, Target, SessionNum, Student&lt;/P&gt;&lt;P&gt;A, 10, 1, John&lt;/P&gt;&lt;P&gt;A, 10, 2, Mark&lt;/P&gt;&lt;P&gt;A, 10, 3, Mark&lt;/P&gt;&lt;P&gt;B, 58, 1, John&lt;/P&gt;&lt;P&gt;B, 58, 2, Kelly&lt;/P&gt;&lt;P&gt;C, 123, 1, Mark&lt;/P&gt;&lt;P&gt;D, 77, 1, Mark&lt;/P&gt;&lt;P&gt;D, 77, 2, John&lt;/P&gt;&lt;P&gt;D, 77, 3, John&lt;/P&gt;&lt;P&gt;D, 77, 4, Kelly&lt;/P&gt;&lt;P&gt;D, 77, 5, John&lt;/P&gt;&lt;P&gt;E, 947, 1, John&lt;/P&gt;&lt;P&gt;E, 947, 2, Kelly&lt;/P&gt;&lt;P&gt;F, 3, 1, Kelly&lt;/P&gt;&lt;P&gt;];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I created a straight table with the following:&lt;/P&gt;&lt;P&gt;Dimension: [Student]&lt;/P&gt;&lt;P&gt;Expression: Sum({1} Aggr(Avg([Target]), [Test]))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The result is:&lt;/P&gt;&lt;P&gt;John | 1015&lt;/P&gt;&lt;P&gt;Kelly | 3&lt;/P&gt;&lt;P&gt;Mark | 200&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can understand how these numbers come about. But when I select just one Student, "Mark", the result becomes this:&lt;/P&gt;&lt;P&gt;John | 10&lt;/P&gt;&lt;P&gt;Mark | 200&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And I can't quite understand why this is so. Is it that QlikView will first look at what Tests that are filtered according to my Student selection (A, C, and D), and then go back to the original data set and pick only these Tests and pass them to the Aggr() function?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance!&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/How-Aggr-handles-selection-with-set-modifier/m-p/1388678#M819542</guid>
      <dc:creator />
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: How Aggr() handles selection with set modifier</title>
      <link>https://community.qlik.com/t5/QlikView/How-Aggr-handles-selection-with-set-modifier/m-p/1388679#M819543</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are looking to ignore selection when you select a student (or any other field)... you need to use {1} in your inner aggregation also&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sum({1} Aggr(Avg(&lt;SPAN style="color: #ff0000;"&gt;{1}&lt;/SPAN&gt;[Target]), [Test]))&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 26 Aug 2017 23:37:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-Aggr-handles-selection-with-set-modifier/m-p/1388679#M819543</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2017-08-26T23:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: How Aggr() handles selection with set modifier</title>
      <link>https://community.qlik.com/t5/QlikView/How-Aggr-handles-selection-with-set-modifier/m-p/1388680#M819544</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks. But I'd like to also understand why the expression behaves this way... so do you mean the Aggr() will honour the selected set first before constructing the virtual table?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 27 Aug 2017 01:19:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-Aggr-handles-selection-with-set-modifier/m-p/1388680#M819544</guid>
      <dc:creator />
      <dc:date>2017-08-27T01:19:00Z</dc:date>
    </item>
    <item>
      <title>Re: How Aggr() handles selection with set modifier</title>
      <link>https://community.qlik.com/t5/QlikView/How-Aggr-handles-selection-with-set-modifier/m-p/1388681#M819545</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you know how nested SQL statements work?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The inner most query is executed first and the results passed on to the one encapsulating it&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Similarly the innermost expression executes first and the results are passed to the expression encapsulating it&lt;/P&gt;&lt;P&gt;so if your inner expressions is set to {$}&amp;nbsp; then the outer {1} will do nothing because your inner expression is still affected by selections&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does that make sense?&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 27 Aug 2017 05:13:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-Aggr-handles-selection-with-set-modifier/m-p/1388681#M819545</guid>
      <dc:creator>vinieme12</dc:creator>
      <dc:date>2017-08-27T05:13:31Z</dc:date>
    </item>
    <item>
      <title>Re: How Aggr() handles selection with set modifier</title>
      <link>https://community.qlik.com/t5/QlikView/How-Aggr-handles-selection-with-set-modifier/m-p/1388682#M819546</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Think about this way that you have created a straight table with Test as dimension and Avg(Target) as expression... when you select something, would you see the selections making impact? You will... right? Now this is the same exact virtual table you are creating and Avg(Target) will filter out non-selected items and the final sum will be based on that. In order to ignore all selections, you need to ignore selections in inner as well as outer aggregations&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sum({1} Aggr(Avg({1}Target), Test))&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Aug 2017 01:07:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-Aggr-handles-selection-with-set-modifier/m-p/1388682#M819546</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2017-08-28T01:07:43Z</dc:date>
    </item>
    <item>
      <title>Re: How Aggr() handles selection with set modifier</title>
      <link>https://community.qlik.com/t5/QlikView/How-Aggr-handles-selection-with-set-modifier/m-p/1388683#M819547</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, thanks again for your advice. I now understand the virtual table resulting from the Aggr() should be something like this after selecting "Mark"&lt;/P&gt;&lt;P&gt;Test | Avg(Target)&lt;/P&gt;&lt;P&gt;A | 10&lt;BR /&gt;C | 123&lt;BR /&gt;D | 77&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But when it's passed to the outer expression, why is John only 10, not 10+77 (since John also appears in Test D)? and Mark is only 200, not 10+123+77 (since Mark also appears in Test A)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Actually I wasn't trying to achieve a particular expression - I was just trying to see how set analysis, TOTAL, and aggr() all come to together...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Aug 2017 06:22:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-Aggr-handles-selection-with-set-modifier/m-p/1388683#M819547</guid>
      <dc:creator />
      <dc:date>2017-08-28T06:22:17Z</dc:date>
    </item>
    <item>
      <title>Re: How Aggr() handles selection with set modifier</title>
      <link>https://community.qlik.com/t5/QlikView/How-Aggr-handles-selection-with-set-modifier/m-p/1388684#M819548</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your advice. I guess I'm just a bit confused on how selections and set analysis work with aggregations. But your explanation clears up a few things for me already. Thanks again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Aug 2017 06:24:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-Aggr-handles-selection-with-set-modifier/m-p/1388684#M819548</guid>
      <dc:creator />
      <dc:date>2017-08-28T06:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: How Aggr() handles selection with set modifier</title>
      <link>https://community.qlik.com/t5/QlikView/How-Aggr-handles-selection-with-set-modifier/m-p/1388685#M819549</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I guess that &lt;STRONG&gt;NODISTINCT&lt;/STRONG&gt; would help you decode the behavior. Aggr() by default returns the distinct output against every possibly combination of output.&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="174825" alt="Capture.PNG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/174825_Capture.PNG" style="height: 311px; width: 620px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Aug 2017 07:09:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-Aggr-handles-selection-with-set-modifier/m-p/1388685#M819549</guid>
      <dc:creator>tresB</dc:creator>
      <dc:date>2017-08-28T07:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: How Aggr() handles selection with set modifier</title>
      <link>https://community.qlik.com/t5/QlikView/How-Aggr-handles-selection-with-set-modifier/m-p/1388686#M819550</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks. By "&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;distinct output against every possibly combination of output", do you mean the resulting virtual table actually includes all the dimensions, not just Test as its only dimension? Because my assumption was that Aggr() is like a SQL GroupBy, so in this case the virtual table should only produce Test as its dimension, and the value is the Aggr() values...&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Aug 2017 09:39:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-Aggr-handles-selection-with-set-modifier/m-p/1388686#M819550</guid>
      <dc:creator />
      <dc:date>2017-08-28T09:39:20Z</dc:date>
    </item>
    <item>
      <title>Re: How Aggr() handles selection with set modifier</title>
      <link>https://community.qlik.com/t5/QlikView/How-Aggr-handles-selection-with-set-modifier/m-p/1388687#M819551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is this what you are hoping to achieve?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture.PNG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/174851_Capture.PNG" style="height: 166px; width: 620px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sum({1} Aggr(Avg({1}[Target]), [Test], Student))&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Aug 2017 11:27:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-Aggr-handles-selection-with-set-modifier/m-p/1388687#M819551</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2017-08-28T11:27:48Z</dc:date>
    </item>
    <item>
      <title>Re: How Aggr() handles selection with set modifier</title>
      <link>https://community.qlik.com/t5/QlikView/How-Aggr-handles-selection-with-set-modifier/m-p/1388688#M819552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks this is helpful. I shall explore more to try to get a better understanding.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Sep 2017 07:36:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-Aggr-handles-selection-with-set-modifier/m-p/1388688#M819552</guid>
      <dc:creator />
      <dc:date>2017-09-01T07:36:23Z</dc:date>
    </item>
  </channel>
</rss>

