<?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 Rangesum in script for last 2 days in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Rangesum-in-script-for-last-2-days/m-p/1949779#M78265</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I need to calculate the RangeSum for the last 2 days where Segment and Article is the same.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I did find a way to make a cumulative sum, but that only works for all dates.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is an example of my dataset. In reality the dataset has millions of rows and i have to calculate for the last 6 months, but for this example let's use 2 days.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data:&lt;BR /&gt;Load * Inline [&lt;BR /&gt;Segment|Article|Date|Amount&lt;BR /&gt;X|1|15-05-2022|2&lt;BR /&gt;X|1|14-05-2022|4&lt;BR /&gt;X|1|13-05-2022|6&lt;BR /&gt;X|2|15-05-2022|12&lt;BR /&gt;X|2|14-05-2022|14&lt;BR /&gt;X|2|13-05-2022|16&lt;BR /&gt;Y|1|15-05-2022|3&lt;BR /&gt;Y|1|14-05-2022|5&lt;BR /&gt;Y|1|13-05-2022|7&lt;BR /&gt;Y|2|15-05-2022|13&lt;BR /&gt;Y|2|14-05-2022|15&lt;BR /&gt;Y|2|13-05-2022|17&lt;BR /&gt;] (delimiter is '|');&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;CumulativeSum:&lt;BR /&gt;Load *,&lt;BR /&gt;if(peek(Segment)=Segment and peek(Article)=Article,rangesum(peek(CumulativeSum),Amount),Amount) as CumulativeSum&lt;/P&gt;
&lt;P&gt;Resident Data&lt;BR /&gt;Order by Article, Segment, Date;&lt;BR /&gt;Drop table Data;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Jun 2022 14:35:19 GMT</pubDate>
    <dc:creator>ariejan</dc:creator>
    <dc:date>2022-06-29T14:35:19Z</dc:date>
    <item>
      <title>Rangesum in script for last 2 days</title>
      <link>https://community.qlik.com/t5/App-Development/Rangesum-in-script-for-last-2-days/m-p/1949779#M78265</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I need to calculate the RangeSum for the last 2 days where Segment and Article is the same.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I did find a way to make a cumulative sum, but that only works for all dates.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is an example of my dataset. In reality the dataset has millions of rows and i have to calculate for the last 6 months, but for this example let's use 2 days.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data:&lt;BR /&gt;Load * Inline [&lt;BR /&gt;Segment|Article|Date|Amount&lt;BR /&gt;X|1|15-05-2022|2&lt;BR /&gt;X|1|14-05-2022|4&lt;BR /&gt;X|1|13-05-2022|6&lt;BR /&gt;X|2|15-05-2022|12&lt;BR /&gt;X|2|14-05-2022|14&lt;BR /&gt;X|2|13-05-2022|16&lt;BR /&gt;Y|1|15-05-2022|3&lt;BR /&gt;Y|1|14-05-2022|5&lt;BR /&gt;Y|1|13-05-2022|7&lt;BR /&gt;Y|2|15-05-2022|13&lt;BR /&gt;Y|2|14-05-2022|15&lt;BR /&gt;Y|2|13-05-2022|17&lt;BR /&gt;] (delimiter is '|');&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;CumulativeSum:&lt;BR /&gt;Load *,&lt;BR /&gt;if(peek(Segment)=Segment and peek(Article)=Article,rangesum(peek(CumulativeSum),Amount),Amount) as CumulativeSum&lt;/P&gt;
&lt;P&gt;Resident Data&lt;BR /&gt;Order by Article, Segment, Date;&lt;BR /&gt;Drop table Data;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2022 14:35:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Rangesum-in-script-for-last-2-days/m-p/1949779#M78265</guid>
      <dc:creator>ariejan</dc:creator>
      <dc:date>2022-06-29T14:35:19Z</dc:date>
    </item>
  </channel>
</rss>

