<?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, all dates, before max date where... in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Sum-all-dates-before-max-date-where/m-p/1224423#M23823</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It probably goes wrong with the dimensions in the AGGR. This part: Cust_Id, Facing, Prod_Id&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a solution?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 20 Feb 2017 11:04:08 GMT</pubDate>
    <dc:creator>ramzi-manoubi</dc:creator>
    <dc:date>2017-02-20T11:04:08Z</dc:date>
    <item>
      <title>Sum, all dates, before max date where...</title>
      <link>https://community.qlik.com/t5/App-Development/Sum-all-dates-before-max-date-where/m-p/1224422#M23822</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Once more, I hope for your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Context: CRM, registering the number of products on the shelf in the stores. I use a treemap to vizualise this, very pretty.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I use this variable to filter, so all data before the max date in the filter would be taken into account. Very standard I think.&lt;/P&gt;&lt;P&gt;vDateBeforeMax&lt;/P&gt;&lt;P&gt;{$&amp;lt;Year=,Quarter=,Month=,Day=,Date={"&amp;lt;=$(=max(Date))"}&amp;gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to take the sum of the most recent facings, before the max date in the filter. To get the most recent registration, I use Last_Reg. The smaller the number, the more recent the registration. This explains following code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(&amp;nbsp;&amp;nbsp;&amp;nbsp; Min($(=vDateBeforeMax)&amp;nbsp;&amp;nbsp;&amp;nbsp; Last_Reg)&amp;nbsp;&amp;nbsp;&amp;nbsp; =&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Min($(=vDateBeforeMax) total&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Prod_Id,Cust_Id&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Last_Reg),&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Facing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tested this structure in other formulas and it works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the complete formula:&lt;/P&gt;&lt;P&gt;Sum($(=vDateBeforeMax)&lt;/P&gt;&lt;P&gt;&amp;nbsp; Aggr($(=vDateBeforeMax)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(&amp;nbsp;&amp;nbsp;&amp;nbsp; Min($(=vDateBeforeMax)&amp;nbsp;&amp;nbsp;&amp;nbsp; Last_Reg)&amp;nbsp;&amp;nbsp;&amp;nbsp; =&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Min($(=vDateBeforeMax) total&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Prod_Id,Cust_Id&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Last_Reg),&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Facing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ), &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Cust_Id, Facing, Prod_Id&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where it goes wrong: When I filter on 2017 I only get for a certain product 6 facings. When I also add 2016 in the filter I have &amp;gt;200 facings.&lt;/P&gt;&lt;P&gt;Having only 2017 in the filter, should already take in account the data for 2016 and all previous years.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Feb 2017 09:50:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Sum-all-dates-before-max-date-where/m-p/1224422#M23822</guid>
      <dc:creator>ramzi-manoubi</dc:creator>
      <dc:date>2017-02-20T09:50:02Z</dc:date>
    </item>
    <item>
      <title>Re: Sum, all dates, before max date where...</title>
      <link>https://community.qlik.com/t5/App-Development/Sum-all-dates-before-max-date-where/m-p/1224423#M23823</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It probably goes wrong with the dimensions in the AGGR. This part: Cust_Id, Facing, Prod_Id&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a solution?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Feb 2017 11:04:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Sum-all-dates-before-max-date-where/m-p/1224423#M23823</guid>
      <dc:creator>ramzi-manoubi</dc:creator>
      <dc:date>2017-02-20T11:04:08Z</dc:date>
    </item>
  </channel>
</rss>

