<?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 of current and previous rows in load script in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Sum-of-current-and-previous-rows-in-load-script/m-p/1996514#M82527</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/103456"&gt;@RsQK&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Thanks so much for your help.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I test with data :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;LOAD * INLINE [&lt;BR /&gt;sortie_stock_pn_ic,sortie_stock_date,sortie_stock_reference&lt;BR /&gt;1234,05/10/2022&lt;BR /&gt;1234,05/05/2023&lt;BR /&gt;1234,06/07/2023,5&lt;BR /&gt;1234,01/10/2024&lt;BR /&gt;1234,11/11/2024&lt;BR /&gt;1234,03/12/2024,1&lt;BR /&gt;1234,12/12/2024,3&lt;BR /&gt;];&lt;/P&gt;
&lt;P&gt;And i have a bad result :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jmialoundama_0-1666690574591.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/92080i713549FB095F75F6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jmialoundama_0-1666690574591.png" alt="jmialoundama_0-1666690574591.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;In the date of 01/10/2024 instead of have 0, i have 5. Is the same for date 11/11/2024, i have 5 instead of 0&lt;/P&gt;</description>
    <pubDate>Tue, 25 Oct 2022 09:37:48 GMT</pubDate>
    <dc:creator>jmialoundama</dc:creator>
    <dc:date>2022-10-25T09:37:48Z</dc:date>
    <item>
      <title>Sum of current and previous rows in load script</title>
      <link>https://community.qlik.com/t5/App-Development/Sum-of-current-and-previous-rows-in-load-script/m-p/1996479#M82521</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;I have this script and this table output:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jmialoundama_0-1666687254255.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/92072i1A772945CC126252/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jmialoundama_0-1666687254255.png" alt="jmialoundama_0-1666687254255.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Donnees_Inline:
LOAD * INLINE [
sortie_stock_pn_ic,sortie_stock_pn_article,sortie_stock_date,sortie_stock_quantite,sortie_stock_reference,sortie_stock_type_mouvement
008Q614,61037916AA,30/09/2022,1,,VP
008Q614,61037916AA,02/02/2023,1,,VP
008Q614,61037916AA,28/02/2023,,3,Peremption
008Q614,61037916AA,30/05/2023,1,,VP
008Q614,61037916AA,02/10/2023,1,,VP
008Q614,61037916AA,31/12/2023,,2,Peremption
008Q614,61037916AA,30/01/2024,1,,VP
008Q614,61037916AA,31/05/2024,,5,Peremption
008Q614,61037916AA,02/06/2024,1,,VP
008Q614,61037916AA,30/09/2024,1,,VP
008Q614,61037916AA,31/12/2024,,1,Peremption
1234,1234BB,05/10/2022,1,,VP
1234,1234BB,05/05/2023,1,,VP
1234,1234BB,06/07/2023,,5,Peremption
1234,1234BB,01/10/2024,1,,VP
1234,1234BB,11/11/2024,,1,Peremption
1234,1234BB,03/12/2024,1,,VP
1234,1234BB,12/12/2024,,3,Peremption
];

NoConcatenate
Donnees:
LOAD 
	sortie_stock_pn_ic &amp;amp; sortie_stock_pn_article as key_ic_article
	, sortie_stock_pn_ic
	,sortie_stock_pn_article
	,date(sortie_stock_date) as sortie_stock_date
	,sortie_stock_quantite
	,sortie_stock_reference
	//,sortie_stock_type_mouvement
Resident Donnees_Inline
ORDER BY sortie_stock_date,sortie_stock_pn_ic,sortie_stock_pn_article;

DROP TABLE Donnees_Inline;


NoConcatenate
Peremptions:
LOAD distinct
    key_ic_article,
    sortie_stock_pn_ic,
    sortie_stock_pn_article,
    sortie_stock_date,
    //sortie_stock_quantite,
    sortie_stock_reference,
    If(Previous(sortie_stock_pn_ic)=sortie_stock_pn_ic AND sortie_stock_reference &amp;lt;&amp;gt;'' ,RANGESUM(sortie_stock_reference,Peek('sortie_stock_reference'))) As Stock_reference_sum
    //sortie_stock_type_mouvement
RESIDENT Donnees
//where sortie_stock_reference &amp;lt;&amp;gt;''
ORDER BY sortie_stock_date,sortie_stock_pn_ic,sortie_stock_pn_article;
    &lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;I want this in final :&amp;nbsp;&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jmialoundama_1-1666687128696.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/92071i5BF45C13442E3BE7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jmialoundama_1-1666687128696.png" alt="jmialoundama_1-1666687128696.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;In my load script i have add this line, but the result is not good :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;If(Previous(sortie_stock_pn_ic)=sortie_stock_pn_ic,RangeSum(sortie_stock_reference,Peek('Stock_reference_sum')),sortie_stock_reference) As Stock_reference_cum&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance for your help&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2022 08:55:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Sum-of-current-and-previous-rows-in-load-script/m-p/1996479#M82521</guid>
      <dc:creator>jmialoundama</dc:creator>
      <dc:date>2022-10-25T08:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: Sum of current and previous rows in load script</title>
      <link>https://community.qlik.com/t5/App-Development/Sum-of-current-and-previous-rows-in-load-script/m-p/1996495#M82523</link>
      <description>&lt;P&gt;Hi, try this script:&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;temp_data:
LOAD * INLINE [
sortie_stock_pn_ic,sortie_stock_date,sortie_stock_reference
1234,05.10.2022,
1234,05.05.2023,
1234,06.07.2023,5
1234,01.10.2024,
1234,11.11.2024,1
1234,03.12.2024,
1234,12.12.2024,3
];

temp_data2:
LOAD *,
sortie_stock_reference	AS sortie_stock_reference_cumulative
RESIDENT temp_data
ORDER BY sortie_stock_pn_ic,sortie_stock_date;

DROP TABLE temp_data;

temp_data3:
NOCONCATENATE
LOAD
sortie_stock_pn_ic,
sortie_stock_date,
sortie_stock_reference,
IF(PREVIOUS(sortie_stock_pn_ic)=sortie_stock_pn_ic,RANGESUM(PEEK(sortie_stock_reference_cumulative),sortie_stock_reference_cumulative,0),RANGESUM(sortie_stock_reference_cumulative,0)) AS sortie_stock_reference_cumulative
RESIDENT temp_data2;

DROP TABLE temp_data2;&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 25 Oct 2022 08:56:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Sum-of-current-and-previous-rows-in-load-script/m-p/1996495#M82523</guid>
      <dc:creator>RsQK</dc:creator>
      <dc:date>2022-10-25T08:56:04Z</dc:date>
    </item>
    <item>
      <title>Re: Sum of current and previous rows in load script</title>
      <link>https://community.qlik.com/t5/App-Development/Sum-of-current-and-previous-rows-in-load-script/m-p/1996514#M82527</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/103456"&gt;@RsQK&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Thanks so much for your help.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I test with data :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;LOAD * INLINE [&lt;BR /&gt;sortie_stock_pn_ic,sortie_stock_date,sortie_stock_reference&lt;BR /&gt;1234,05/10/2022&lt;BR /&gt;1234,05/05/2023&lt;BR /&gt;1234,06/07/2023,5&lt;BR /&gt;1234,01/10/2024&lt;BR /&gt;1234,11/11/2024&lt;BR /&gt;1234,03/12/2024,1&lt;BR /&gt;1234,12/12/2024,3&lt;BR /&gt;];&lt;/P&gt;
&lt;P&gt;And i have a bad result :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jmialoundama_0-1666690574591.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/92080i713549FB095F75F6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jmialoundama_0-1666690574591.png" alt="jmialoundama_0-1666690574591.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;In the date of 01/10/2024 instead of have 0, i have 5. Is the same for date 11/11/2024, i have 5 instead of 0&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2022 09:37:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Sum-of-current-and-previous-rows-in-load-script/m-p/1996514#M82527</guid>
      <dc:creator>jmialoundama</dc:creator>
      <dc:date>2022-10-25T09:37:48Z</dc:date>
    </item>
  </channel>
</rss>

