<?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: Partial aggregation in straight table in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Partial-aggregation-in-straight-table/m-p/1067267#M929285</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="119345" alt="Capture.PNG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/119345_Capture.PNG" style="max-width: 620px; height: auto;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 24 Mar 2016 15:00:57 GMT</pubDate>
    <dc:creator>sunny_talwar</dc:creator>
    <dc:date>2016-03-24T15:00:57Z</dc:date>
    <item>
      <title>Partial aggregation in straight table</title>
      <link>https://community.qlik.com/t5/QlikView/Partial-aggregation-in-straight-table/m-p/1067266#M929284</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to do an aggregation on a table that does not exist in the data model, but is dynamically created as a straight table in the GUI. In my data model, I have two tables, one giving the current stock of all articles, and one the expected transactions over the next month. From this, I compute the required orders in a straight table as:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 13.3333px;"&gt; [required orders] = rangemmax(0, -1*(Stock+[Goods receipt]-[Goods sold]))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The table might look like this (see also attached qvw):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="124" style="border: 1px solid rgb(0, 0, 0); width: 185px; height: 121px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;ArtID&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Size&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;required orders&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;P&gt;001&lt;/P&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;L&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;001&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;M&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;002&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;M&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;002&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;S&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I want an aggregated table, that just gives the sum of required orders per article ID, across all sizes:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="74" style="border: 1px solid #000000; width: 150px; height: 72px;" width="148"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;ArtID&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;required orders&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;001&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;002&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;A simple pivot table won't work, because&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; I only need to order an item if I predict the stock to go below zero. But if I aggregate, the current stock will also be aggregated before the substraction and addition of the transactions, and thus the result won't be correct. For example, if I have 100 size M items of article 001, then the aggregation won't tell me that I still need to order 5 items of this article because I'm running out of size L.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;It would be easy if I computed the first table in the script, but I cannot do that, because the user needs to be able to dynamically pick a date for which the required orders should be computed (see qvw-file). Any ideas how to achieve this?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help!&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/Partial-aggregation-in-straight-table/m-p/1067266#M929284</guid>
      <dc:creator />
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Partial aggregation in straight table</title>
      <link>https://community.qlik.com/t5/QlikView/Partial-aggregation-in-straight-table/m-p/1067267#M929285</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="119345" alt="Capture.PNG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/119345_Capture.PNG" style="max-width: 620px; height: auto;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Mar 2016 15:00:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Partial-aggregation-in-straight-table/m-p/1067267#M929285</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2016-03-24T15:00:57Z</dc:date>
    </item>
    <item>
      <title>Re: Partial aggregation in straight table</title>
      <link>https://community.qlik.com/t5/QlikView/Partial-aggregation-in-straight-table/m-p/1067268#M929286</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot! It's not quite what I need yet, because I can't simply take the min, in case more than one size of an article goes below 0, and I need to add those together. But you pointed me in the right direction, and I think I got it now, with an additional if statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum(if(Aggr(Stock + sum({$&amp;lt;Date={"&amp;lt;=$(vOrderDate)"}&amp;gt;} [Goods receipt]) - sum({$&amp;lt;Date={"&amp;lt;=$(vOrderDate)"}&amp;gt;}[Goods sold]), ArtID, Size)&amp;lt;0,&lt;/P&gt;&lt;P&gt;Aggr(Stock + sum({$&amp;lt;Date={"&amp;lt;=$(vOrderDate)"}&amp;gt;} [Goods receipt]) - sum({$&amp;lt;Date={"&amp;lt;=$(vOrderDate)"}&amp;gt;}[Goods sold]), ArtID, Size)))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not sure how well this will perform with a lot of data, but at least it computes what I need. So thanks again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Mar 2016 15:28:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Partial-aggregation-in-straight-table/m-p/1067268#M929286</guid>
      <dc:creator />
      <dc:date>2016-03-24T15:28:36Z</dc:date>
    </item>
  </channel>
</rss>

