<?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: Calculate Difference Quantity based on Previous Date in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Calculate-Difference-Quantity-based-on-Previous-Date/m-p/1269003#M622664</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ibrahim,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I understand the condition, it may be&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table0:&lt;/P&gt;&lt;P&gt;LOAD * Inline&lt;/P&gt;&lt;P&gt;[Date, Material, Quantity, Final Quantity &lt;/P&gt;&lt;P&gt;12.12.2016, 10004, 280, 350&lt;/P&gt;&lt;P&gt;11.11.2016, 10004, 60, 350&lt;/P&gt;&lt;P&gt;10.10.2016, 10004, 700, 350&lt;/P&gt;&lt;P&gt;10.3.2016, 10004, 100, 350];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Left Join&lt;/P&gt;&lt;P&gt;LOAD*,&lt;/P&gt;&lt;P&gt;Previous(RangeSum(Quantity, Peek('Bsum'))) as Bsum,&lt;EM&gt; //accumulating a total of Quantity in Bsum with offset by one line&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;If(Quantity &amp;gt; [Final Quantity], [Final Quantity] - Previous(RangeSum(Quantity, Peek('Bsum'))), Quantity) as [Max Quantity] &lt;EM&gt;//We check the condition&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Resident Table0;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Result&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="1.jpg" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/151537_1.jpg" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Andrey&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 01 Feb 2017 09:22:10 GMT</pubDate>
    <dc:creator>ahaahaaha</dc:creator>
    <dc:date>2017-02-01T09:22:10Z</dc:date>
    <item>
      <title>Calculate Difference Quantity based on Previous Date</title>
      <link>https://community.qlik.com/t5/QlikView/Calculate-Difference-Quantity-based-on-Previous-Date/m-p/1269002#M622663</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Qlik community,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;first of all thank you in advance for your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hopefully, you have an idea and solution for my problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My Table has four columns, which are sorted by Date (Newest to Oldest). The Table contains different Material numbers, but for each Material number the "Final Quantity" is always the same. All quantities are always positive numbers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 333px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD height="19" style="font-size: 11pt; color: black; font-weight: bold; font-family: Calibri; border-width: 0.5pt 0.5pt 1pt; border-style: solid; border-color: black;" width="76"&gt;Date&lt;/TD&gt;&lt;TD style="font-size: 11pt; color: black; font-weight: bold; font-family: Calibri; border-width: 0.5pt 0.5pt 1pt; border-style: solid; border-color: black;" width="74"&gt;Material&lt;/TD&gt;&lt;TD style="font-size: 11pt; color: black; font-weight: bold; font-family: Calibri; border-width: 0.5pt 0.5pt 1pt; border-style: solid; border-color: black;" width="76"&gt;&lt;SPAN style="color: #0000ff;"&gt;Quantity&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="font-size: 11pt; color: black; font-weight: bold; font-family: Calibri; border-width: 0.5pt 0.5pt 1pt; border-style: solid; border-color: black;" width="107"&gt;&lt;SPAN style="color: #ff0000;"&gt;Final Quantity&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl63" height="19" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black; background: #d9d9d9;"&gt;12/12/2016&lt;/TD&gt;&lt;TD align="right" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black; background: #d9d9d9;"&gt;10004&lt;/TD&gt;&lt;TD align="right" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black; background: #d9d9d9;"&gt;280&lt;/TD&gt;&lt;TD align="right" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black; background: #d9d9d9;"&gt;350&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl63" height="19" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black;"&gt;11/11/2016&lt;/TD&gt;&lt;TD align="right" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black;"&gt;10004&lt;/TD&gt;&lt;TD align="right" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black;"&gt;60&lt;/TD&gt;&lt;TD align="right" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black;"&gt;350&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl63" height="19" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black; background: #d9d9d9;"&gt;10/10/2016&lt;/TD&gt;&lt;TD align="right" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black; background: #d9d9d9;"&gt;10004&lt;/TD&gt;&lt;TD align="right" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black; background: #d9d9d9;"&gt;700&lt;/TD&gt;&lt;TD align="right" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black; background: #d9d9d9;"&gt;350&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl63" height="19" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black;"&gt;10/3/2016&lt;/TD&gt;&lt;TD align="right" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black;"&gt;10004&lt;/TD&gt;&lt;TD align="right" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black;"&gt;100&lt;/TD&gt;&lt;TD align="right" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black;"&gt;350&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to create a new table with a new column "Max Quantity". &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The new column should be contain the same information like column "Quantity"&lt;STRONG&gt;, but&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;IF&lt;/STRONG&gt; the &lt;SPAN style="text-decoration: underline;"&gt;SUM of the previous "Quantity&lt;/SPAN&gt;" [based on Date] is reached, then &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;calculate a Difference&lt;/STRONG&gt; between "Final Quantity" and &lt;SPAN style="text-decoration: underline;"&gt;Sum of the previous "Quantity".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 439px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD height="19" style="font-size: 11pt; color: black; font-weight: bold; font-family: Calibri; border-width: 0.5pt 0.5pt 1pt; border-style: solid; border-color: black;" width="76"&gt;Date&lt;/TD&gt;&lt;TD style="font-size: 11pt; color: black; font-weight: bold; font-family: Calibri; border-width: 0.5pt 0.5pt 1pt; border-style: solid; border-color: black;" width="74"&gt;Material&lt;/TD&gt;&lt;TD style="font-size: 11pt; color: black; font-weight: bold; font-family: Calibri; border-width: 0.5pt 0.5pt 1pt; border-style: solid; border-color: black;" width="76"&gt;&lt;SPAN style="color: #0000ff;"&gt;Quantity&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="font-size: 11pt; color: black; font-weight: bold; font-family: Calibri; border-width: 0.5pt 0.5pt 1pt; border-style: solid; border-color: black;" width="107"&gt;&lt;SPAN style="color: #ff0000;"&gt;Final Quantity&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="font-size: 11pt; color: black; font-weight: bold; font-family: Calibri; border-width: 0.5pt 0.5pt 1pt; border-style: solid; border-color: black;" width="106"&gt;&lt;SPAN style="color: #339966;"&gt;Max Quantity&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="19" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black; background: #d9d9d9;"&gt;12/12/2016&lt;/TD&gt;&lt;TD align="right" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black; background: #d9d9d9;"&gt;10004&lt;/TD&gt;&lt;TD align="right" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black; background: #d9d9d9;"&gt;280&lt;/TD&gt;&lt;TD align="right" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black; background: #d9d9d9;"&gt;350&lt;/TD&gt;&lt;TD align="right" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black; background: #d9d9d9;"&gt;280&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="19" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black;"&gt;11/11/2016&lt;/TD&gt;&lt;TD align="right" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black;"&gt;10004&lt;/TD&gt;&lt;TD align="right" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black;"&gt;60&lt;/TD&gt;&lt;TD align="right" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black;"&gt;350&lt;/TD&gt;&lt;TD align="right" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black;"&gt;60&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="19" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black; background: #d9d9d9;"&gt;10/10/2016&lt;/TD&gt;&lt;TD align="right" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black; background: #d9d9d9;"&gt;10004&lt;/TD&gt;&lt;TD align="right" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black; background: #d9d9d9;"&gt;700&lt;/TD&gt;&lt;TD align="right" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black; background: #d9d9d9;"&gt;350&lt;/TD&gt;&lt;TD align="right" style="font-size: 11pt; color: black; font-family: Calibri; border: 0.5pt solid black; background: #d9d9d9;"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this example the the column Quantity has on Date 10/10/2016 more then 350 quantities, so the Max Quantity is only the difference 10.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am working on this problem since a few days and I searched for solutions in Qlik community, but i didn't find one.&lt;/P&gt;&lt;P&gt;Hopefully, you have an idea.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Ibr&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2017 00:43:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculate-Difference-Quantity-based-on-Previous-Date/m-p/1269002#M622663</guid>
      <dc:creator />
      <dc:date>2017-02-01T00:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Difference Quantity based on Previous Date</title>
      <link>https://community.qlik.com/t5/QlikView/Calculate-Difference-Quantity-based-on-Previous-Date/m-p/1269003#M622664</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ibrahim,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I understand the condition, it may be&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table0:&lt;/P&gt;&lt;P&gt;LOAD * Inline&lt;/P&gt;&lt;P&gt;[Date, Material, Quantity, Final Quantity &lt;/P&gt;&lt;P&gt;12.12.2016, 10004, 280, 350&lt;/P&gt;&lt;P&gt;11.11.2016, 10004, 60, 350&lt;/P&gt;&lt;P&gt;10.10.2016, 10004, 700, 350&lt;/P&gt;&lt;P&gt;10.3.2016, 10004, 100, 350];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Left Join&lt;/P&gt;&lt;P&gt;LOAD*,&lt;/P&gt;&lt;P&gt;Previous(RangeSum(Quantity, Peek('Bsum'))) as Bsum,&lt;EM&gt; //accumulating a total of Quantity in Bsum with offset by one line&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;If(Quantity &amp;gt; [Final Quantity], [Final Quantity] - Previous(RangeSum(Quantity, Peek('Bsum'))), Quantity) as [Max Quantity] &lt;EM&gt;//We check the condition&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Resident Table0;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Result&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="1.jpg" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/151537_1.jpg" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Andrey&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2017 09:22:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculate-Difference-Quantity-based-on-Previous-Date/m-p/1269003#M622664</guid>
      <dc:creator>ahaahaaha</dc:creator>
      <dc:date>2017-02-01T09:22:10Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Difference Quantity based on Previous Date</title>
      <link>https://community.qlik.com/t5/QlikView/Calculate-Difference-Quantity-based-on-Previous-Date/m-p/1269004#M622665</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/qlik-users/150954"&gt;ahaahaaha&lt;/A&gt; Hi Andrey,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you very much for your response.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I took your code and added a CumulativeQuantity, see code below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Left Join&lt;/P&gt;&lt;P&gt;LOAD*,&lt;/P&gt;&lt;P&gt;&amp;nbsp; Previous(RangeSum(Quantity, Peek('Bsum'))) as Bsum, //accumulating a total of Quantity in Bsum with offset by one line&lt;/P&gt;&lt;P&gt;&amp;nbsp; If(Quantity &amp;gt; [Final Quantity], [Final Quantity] - Previous(RangeSum(Quantity, Peek('Bsum'))), Quantity) as [Max Quantity], //We check the condition&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;If(RowNo()=1, Quantity, If(Material = Peek(Material),Quantity + Peek(CumulativeQuantity),Quantity)) AS [CumulativeQuantity] //calculate cumulative&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Resident Table0;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Table.png" class="jive-image image-1" height="162" src="https://community.qlik.com/legacyfs/online/151585_Table.png" style="height: 162.389px; width: 757px;" width="757" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, I would like to delete the red line. Because the Sum of the "Max Quantity" is equal to "Final Quantity".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you have an idea, how its possible to do it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Ibr&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2017 14:23:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculate-Difference-Quantity-based-on-Previous-Date/m-p/1269004#M622665</guid>
      <dc:creator />
      <dc:date>2017-02-01T14:23:44Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Difference Quantity based on Previous Date</title>
      <link>https://community.qlik.com/t5/QlikView/Calculate-Difference-Quantity-based-on-Previous-Date/m-p/1269005#M622666</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A _jive_internal="true" class="jiveTT-hover-user jive-link-profile-small" data-containerid="-1" data-containertype="-1" data-objectid="150954" data-objecttype="3" href="https://community.qlik.com/people/ahaahaaha" style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3778c7;"&gt;ahaahaaha&lt;/A&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt; Hi Andrey,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;i did it with you help. Thank you very much.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;STRONG&gt;My code:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Table0:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;LOAD * Inline&lt;/P&gt;&lt;P&gt;[Date, Material, Quantity, Final Quantity&lt;/P&gt;&lt;P&gt;12.12.2016, 10004, 280, 350&lt;/P&gt;&lt;P&gt;11.11.2016, 10004, 60, 350&lt;/P&gt;&lt;P&gt;10.10.2016, 10004, 700, 350&lt;/P&gt;&lt;P&gt;10.3.2016, 10004, 100, 350];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Left Join&lt;/P&gt;&lt;P&gt;LOAD*,&lt;/P&gt;&lt;P&gt;&amp;nbsp; Previous(RangeSum(Quantity, Peek('Bsum'))) as Bsum, //accumulating a total of Quantity in Bsum with offset by one line&lt;/P&gt;&lt;P&gt;&amp;nbsp; If(Quantity &amp;gt; [Final Quantity], [Final Quantity] - Previous(RangeSum(Quantity, Peek('Bsum'))), Quantity) as [Max Quantity], //We check the condition&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; If(RowNo()=1, Quantity, If(Material = Peek(Material),Quantity + Peek(CumulativeQuantity),Quantity)) AS [CumulativeQuantity] //cumulative quantity&lt;/P&gt;&lt;P&gt;Resident Table0;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Table1:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;NoConcatenate&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Load *,&lt;/P&gt;&lt;P&gt;If(RowNo()=1, Quantity, If(Material = Peek(Material),[Max Quantity] + (Previous(RangeSum([Max Quantity], Peek('Bsum')))),0)) AS [Max CumulativeQuantity]&lt;/P&gt;&lt;P&gt;Resident Table0;&lt;/P&gt;&lt;P&gt;Drop Table Table0;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Table2:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;NoConcatenate&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Load *&lt;/P&gt;&lt;P&gt;Resident Table1&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Where [Max CumulativeQuantity]&amp;lt;=[Final Quantity];&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Drop Table Table1;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Table2.JPG" class="jive-image image-1" height="148" src="https://community.qlik.com/legacyfs/online/151604_Table2.JPG" style="height: 148.323px; width: 968px;" width="968" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I created a new column "Max CumulativeQuantity" based on "Max Quantity". &lt;/P&gt;&lt;P&gt;And I added &lt;STRONG style="font-size: 13.3333px;"&gt;Where [Max CumulativeQuantity]&amp;lt;=[Final Quantity];&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Ibr&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2017 15:06:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculate-Difference-Quantity-based-on-Previous-Date/m-p/1269005#M622666</guid>
      <dc:creator />
      <dc:date>2017-02-01T15:06:23Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Difference Quantity based on Previous Date</title>
      <link>https://community.qlik.com/t5/QlikView/Calculate-Difference-Quantity-based-on-Previous-Date/m-p/1269006#M622667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ibr , How you are marking your answer as correct ?&amp;nbsp; @&lt;STRONG style="font-size: 11.7px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;A href="https://community.qlik.com/people/ahaahaaha"&gt;ahaahaaha&lt;/A&gt;&lt;/STRONG&gt;&amp;nbsp; has responded and helped you. You have to mark his answer as correct answer. You should refrain to do this.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2017 15:46:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculate-Difference-Quantity-based-on-Previous-Date/m-p/1269006#M622667</guid>
      <dc:creator>jayanttibhe</dc:creator>
      <dc:date>2017-02-01T15:46:22Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Difference Quantity based on Previous Date</title>
      <link>https://community.qlik.com/t5/QlikView/Calculate-Difference-Quantity-based-on-Previous-Date/m-p/1269007#M622668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A href="https://community.qlik.com/qlik-users/150763"&gt;jayanttibhe&lt;/A&gt;‌,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;as I know "correct answer" means that question or problem is answered. &lt;A _jive_internal="true" class="jiveTT-hover-user jive-link-profile-small" data-containerid="-1" data-containertype="-1" data-objectid="150954" data-objecttype="3" href="https://community.qlik.com/people/ahaahaaha"&gt;&lt;STRONG style="color: #3778c7;"&gt;Andrey Khoronenko&lt;/STRONG&gt;&lt;/A&gt; helped me a lot and I wrote several times "thank you for your help".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a nice day.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Ibr&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2017 15:53:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculate-Difference-Quantity-based-on-Previous-Date/m-p/1269007#M622668</guid>
      <dc:creator />
      <dc:date>2017-02-01T15:53:30Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Difference Quantity based on Previous Date</title>
      <link>https://community.qlik.com/t5/QlikView/Calculate-Difference-Quantity-based-on-Previous-Date/m-p/1269008#M622669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Hi &lt;/SPAN&gt;&lt;A _jive_internal="true" class="jiveTT-hover-user jive-link-profile-small" data-containerid="-1" data-containertype="-1" data-objectid="150763" data-objecttype="3" href="https://community.qlik.com/people/jayanttibhe" style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3778c7;"&gt;jayanttibhe&lt;/A&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;, &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Hi &lt;STRONG style="font-size: 11.7px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;A _jive_internal="true" class="jiveTT-hover-user jive-link-profile-small" data-containerid="-1" data-containertype="-1" data-objectid="150954" data-objecttype="3" href="https://community.qlik.com/people/ahaahaaha" style="font-weight: inherit; font-style: inherit; font-size: 11.7px; font-family: inherit; color: #3778c7;"&gt;Andrey Khoronenko,&lt;/A&gt;&lt;/STRONG&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;I changed the Input data from sorted by date to unsorted. And I added new material. Now, the whole code doesn't work.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Maybe you can help me. &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;Table0:&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;LOAD * Inline&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;[Date, Material, Quantity, Final Quantity&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;12/12/2016, 10004, 280, 350&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;11/11/2016, 10005, 60, 250&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;10/10/2016, 10004, 700, 350&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;12/13/2016, 10007, 40,300&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;12/14/2016, 10007, 40,300&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;12/29/2016, 10007, 40,300&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;12/11/2016, 10007, 40,300&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;12/1/2016, 10007, 40,300&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;12/23/2016, 10007, 40,300&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;10/3/2016, 10004, 100, 350&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;10/12/2016, 10005, 280, 250&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;12/12/2016, 10006, 440,400&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;1/11/2016, 10005, 60, 250&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;9/9/2016, 10005, 700, 250&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;12/27/2016, 10007, 40,300&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;12/23/2016, 10007, 40,300&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;10/4/2016, 10005, 100, 250&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;12/23/2016, 10007, 40,300];&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;I would very much welcome any ideas and help. Thanks a lot.&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;Best regards,&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Ibr&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2017 16:23:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculate-Difference-Quantity-based-on-Previous-Date/m-p/1269008#M622669</guid>
      <dc:creator />
      <dc:date>2017-02-01T16:23:27Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Difference Quantity based on Previous Date</title>
      <link>https://community.qlik.com/t5/QlikView/Calculate-Difference-Quantity-based-on-Previous-Date/m-p/1269009#M622670</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ibrahim,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is necessary to load the table with the selection condition&amp;nbsp; like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD*&lt;/P&gt;&lt;P&gt;Resident Table0&lt;/P&gt;&lt;P&gt;Where [&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Max Quantity] &amp;lt;&amp;gt; [&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Final Quantity&lt;/SPAN&gt;];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Andrey&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Feb 2017 08:12:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculate-Difference-Quantity-based-on-Previous-Date/m-p/1269009#M622670</guid>
      <dc:creator>ahaahaaha</dc:creator>
      <dc:date>2017-02-02T08:12:22Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Difference Quantity based on Previous Date</title>
      <link>https://community.qlik.com/t5/QlikView/Calculate-Difference-Quantity-based-on-Previous-Date/m-p/1269010#M622671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 13.3333px;"&gt;Hi Ibrahim,&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;Maybe so? The basis given above I took my code. You can make it their own changes as written above.&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P&gt;Table0:&lt;/P&gt;&lt;P&gt;LOAD * Inline&lt;/P&gt;&lt;P&gt;[Date, Material, Quantity, Final Quantity&lt;/P&gt;&lt;P&gt;12.12.2016, 10004, 280, 350&lt;/P&gt;&lt;P&gt;11.11.2016, 10005, 60, 250&lt;/P&gt;&lt;P&gt;10.10.2016, 10004, 700, 350&lt;/P&gt;&lt;P&gt;13.12.2016, 10007, 40,300&lt;/P&gt;&lt;P&gt;14.12.2016, 10007, 40,300&lt;/P&gt;&lt;P&gt;29.12.2016, 10007, 40,300&lt;/P&gt;&lt;P&gt;11.12.2016, 10007, 40,300&lt;/P&gt;&lt;P&gt;01.12.2016, 10007, 40,300&lt;/P&gt;&lt;P&gt;23.12.2016, 10007, 40,300&lt;/P&gt;&lt;P&gt;3.10.2016, 10004, 100, 350&lt;/P&gt;&lt;P&gt;12.10.2016, 10005, 280, 250&lt;/P&gt;&lt;P&gt;12.12.2016, 10006, 440,400&lt;/P&gt;&lt;P&gt;11.01.2016, 10005, 60, 250&lt;/P&gt;&lt;P&gt;09.09.2016, 10005, 700, 250&lt;/P&gt;&lt;P&gt;27.12.2016, 10007, 40,300&lt;/P&gt;&lt;P&gt;23.12.2016, 10007, 40,300&lt;/P&gt;&lt;P&gt;04.10.2016, 10005, 100, 250&lt;/P&gt;&lt;P&gt;23.12.2016, 10007, 40,300];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;//overload the table, sorted by date&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;NoConcatenate&lt;/P&gt;&lt;P&gt;Table1:&lt;/P&gt;&lt;P&gt;LOAD*&lt;/P&gt;&lt;P&gt;Resident Table0&lt;/P&gt;&lt;P&gt;Order By Date desc;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;//further all as above&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Left Join&lt;/P&gt;&lt;P&gt;LOAD*,&lt;/P&gt;&lt;P&gt;Previous(RangeSum(Quantity, Peek('Bsum'))) as Bsum, //accumulating a total of Quantity in Bsum with offset by one line&lt;/P&gt;&lt;P&gt;If(Quantity &amp;gt; [Final Quantity], [Final Quantity] - Previous(RangeSum(Quantity, Peek('Bsum'))), Quantity) as [Max Quantity] //We check the condition&lt;/P&gt;&lt;P&gt;Resident Table1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DROP Table Table0;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;Regards,&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;Andrey&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Feb 2017 08:18:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculate-Difference-Quantity-based-on-Previous-Date/m-p/1269010#M622671</guid>
      <dc:creator>ahaahaaha</dc:creator>
      <dc:date>2017-02-02T08:18:07Z</dc:date>
    </item>
  </channel>
</rss>

