<?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: Cumulative Rolling Months in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Cumulative-Rolling-Months/m-p/1863560#M71270</link>
    <description>&lt;P&gt;Sort by expression&lt;/P&gt;
&lt;P&gt;=Max(MonthStartDate)&lt;/P&gt;</description>
    <pubDate>Thu, 25 Nov 2021 11:54:26 GMT</pubDate>
    <dc:creator>vinieme12</dc:creator>
    <dc:date>2021-11-25T11:54:26Z</dc:date>
    <item>
      <title>Cumulative Rolling Months</title>
      <link>https://community.qlik.com/t5/App-Development/Cumulative-Rolling-Months/m-p/1858854#M70899</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;I am looking to create a 24 month reporting period where the date behind each month is the sum of the current month and the preceding 11 month. This 24 month period will roll each month, with the last month dropping off.&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;So&amp;nbsp;for example, month one is October-2018 and is backed by&amp;nbsp; Nov 2017- October 2018 data, and September 2018 is back by August 2017- October 2018 data and so on so forth.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I have managed to get the rolling period working for the most recent 12 period. However, I cant get rid of the rest of the axis, and also I would prefer to show it like the second screenshot attachment&amp;nbsp;where I have a current RYTD(first 1-12 months) vs the pervious RYTD(13-24&amp;nbsp; months).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Attached is a sample of data to show how the file looks that I have used. It's completely fictitious. Where I have order Id it would usually be a&amp;nbsp; distinct&amp;nbsp;code but I have replaced it with a single letter that is duplicated.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;My data load can be seen in the third screen shot.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;The code I have so far which has generated the first screenshot is as follows:&lt;/P&gt;
&lt;P&gt;RangeSum(Above(Aggr(count(OrderNo),RMonthYear),0,12))*AVG({&amp;lt; Day_Ordered = {"$(='&amp;gt;' &amp;amp; Date(AddMonths(Max(Day_Ordered),-12))&amp;amp; '&amp;lt;=' &amp;amp; Date(AddMonths(Max(Day_Ordered),0)))"}&amp;gt;}1)&lt;/P&gt;
&lt;P&gt;Thanks for the help, I've been stuck on this for ages.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="alexwb_1-1636739926584.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/66583i95760CE21AC12CEE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="alexwb_1-1636739926584.png" alt="alexwb_1-1636739926584.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="alexwb_2-1636739942234.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/66584i24FAF02E5D4D3AA2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="alexwb_2-1636739942234.png" alt="alexwb_2-1636739942234.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="alexwb_3-1636740400723.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/66585iEB818245F9E5724B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="alexwb_3-1636740400723.png" alt="alexwb_3-1636740400723.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Nov 2021 18:08:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Cumulative-Rolling-Months/m-p/1858854#M70899</guid>
      <dc:creator>alex-wb</dc:creator>
      <dc:date>2021-11-12T18:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative Rolling Months</title>
      <link>https://community.qlik.com/t5/App-Development/Cumulative-Rolling-Months/m-p/1859082#M70914</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/135685"&gt;@alex-wb&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Firstly, Thanks for the great question and for teaching me something new. I've come across this same issue of allocating previous months' aggregations against a specific month in a visualisation and you provided some great code to be able to accomplish that.&lt;/P&gt;
&lt;P&gt;According to your excel you wanted a comparison of the months for the previous and current. I think this poses a little problem with the above function because it's only going to look at 1 to 12 instead of different months and years when aggregating.&lt;/P&gt;
&lt;P&gt;You may have thought of this already or potentially not wanted to add any code to the data load but my solution is to create a reference table that allocates a reporting year and month against your RMonthYear.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[Data]:&lt;BR /&gt;LOAD&lt;BR /&gt;[OrderNo],&lt;BR /&gt;[Ordered_Day] as [Day_Ordered],&lt;BR /&gt;monthstart([Ordered_Day],0) as RMonthYear,&lt;BR /&gt;month([Ordered_Day]) as RMonth&lt;BR /&gt;FROM [lib://AttachedFiles/Rolling Data.xlsx]&lt;BR /&gt;(ooxml, embedded labels, table is Data);&lt;/P&gt;
&lt;P&gt;//This section loads a distinct list of the RMonthYear and loops through the dates 12 times, each time allocating 1 month further into the future creating an association with that RMonthYear and the next 12 months.&lt;/P&gt;
&lt;P&gt;for i = 0 to 11&lt;BR /&gt;MasterCalendar:&lt;BR /&gt;Load&lt;BR /&gt;month(monthstart(RMonthYear, $(i))) as MasterDateMonth,&lt;BR /&gt;monthstart(RMonthYear, $(i)) as MasterDates,&lt;BR /&gt;RMonthYear&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;Load Distinct&lt;BR /&gt;RMonthYear&lt;BR /&gt;Resident Data;&lt;BR /&gt;next i;&lt;/P&gt;
&lt;P&gt;In your Bar chart you use:&lt;/P&gt;
&lt;P&gt;Dimension =&amp;nbsp;MasterDateMonth&lt;/P&gt;
&lt;P&gt;Previous RYTD =&amp;nbsp;Count({$&amp;lt;MasterDates={"&amp;gt;=$(=addmonths(max(RMonthYear),-23))&amp;lt;=$(=addmonths(max(RMonthYear),-12))"}&amp;gt;}OrderNo)&lt;/P&gt;
&lt;P&gt;Current RYTD =&amp;nbsp;Count({$&amp;lt;MasterDates={"&amp;gt;=$(=addmonths(max(RMonthYear),-11))&amp;lt;=$(=max(RMonthYear))"}&amp;gt;}OrderNo)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="anthonyj_0-1636939717273.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/66612iE6BCF6026CBD18FA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="anthonyj_0-1636939717273.png" alt="anthonyj_0-1636939717273.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I'd still love to see if someone could do this in set analysis alone but in the mean time I hope this helps.&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Anthony&lt;/P&gt;</description>
      <pubDate>Mon, 15 Nov 2021 01:31:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Cumulative-Rolling-Months/m-p/1859082#M70914</guid>
      <dc:creator>anthonyj</dc:creator>
      <dc:date>2021-11-15T01:31:00Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative Rolling Months</title>
      <link>https://community.qlik.com/t5/App-Development/Cumulative-Rolling-Months/m-p/1859287#M70927</link>
      <description>&lt;P&gt;There is no need to load the same data for each month, simply create an AsOf table and associate the preceding month dates&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Order:&lt;BR /&gt;LOAD OrderNo, &lt;BR /&gt;Ordered_Day,&lt;BR /&gt;MonthStart(Date(Ordered_Day,'MMM-YYYY')) as MonthStartDate&lt;BR /&gt;,Month(Date(Ordered_Day,'MMM-YYYY')) as ActualMonth&lt;BR /&gt;FROM&lt;BR /&gt;[D:\QlikCommunity\Rolling Data.xlsx]&lt;BR /&gt;(ooxml, embedded labels, table is Data);&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;temp:&lt;/P&gt;
&lt;P&gt;Load &lt;BR /&gt;date(FieldValue('MonthStartDate',IterNo())) as RollingMonthDate&lt;BR /&gt;,recno() as r&lt;BR /&gt;AutoGenerate 12&lt;BR /&gt;WHILE len(fieldvalue('MonthStartDate',iterno()));&lt;/P&gt;
&lt;P&gt;NoConcatenate&lt;BR /&gt;AsOf:&lt;BR /&gt;Load&lt;BR /&gt;*&lt;BR /&gt;,Month(RollingMonthDate) as RollingMonth&lt;BR /&gt;,monthstart(RollingMonthDate,1-r) as MonthStartDate&lt;BR /&gt;Resident temp;&lt;BR /&gt;Drop table temp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Dimension&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;RollingMonth&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;expressions&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Count({$&amp;lt;RollingMonthDate={"&amp;gt;=$(=Monthstart(max(MonthStartDate),-23))&amp;lt;=$(=Monthstart(max(MonthStartDate),-12))"}&amp;gt;}OrderNo)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Count({$&amp;lt;RollingMonthDate={"&amp;gt;=$(=Monthstart(max(MonthStartDate),-11))&amp;lt;=$(=Monthstart(max(MonthStartDate)))"}&amp;gt;}OrderNo)&lt;/P&gt;</description>
      <pubDate>Mon, 15 Nov 2021 10:59:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Cumulative-Rolling-Months/m-p/1859287#M70927</guid>
      <dc:creator>vinieme12</dc:creator>
      <dc:date>2021-11-15T10:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative Rolling Months</title>
      <link>https://community.qlik.com/t5/App-Development/Cumulative-Rolling-Months/m-p/1859427#M70933</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/1157"&gt;@anthonyj&lt;/a&gt;&amp;nbsp; and&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/2751"&gt;@vinieme12&lt;/a&gt;&amp;nbsp; , thank you both very much for your response, both solutions work :).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/1157"&gt;@anthonyj&lt;/a&gt;&amp;nbsp; I have seen a version of it that doesn't require you to do it through the data load script, but this was with data that had already been aggregated in SQL to a month level, so you would need to do it somewhere separately if you wished to retain individual order codes.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/2751"&gt;@vinieme12&lt;/a&gt;&amp;nbsp; Thanks for the Asoftable code, can I ask how it works? Also, I guess the two dates could be included in a master calendar?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once again thank you both very much.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Nov 2021 15:10:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Cumulative-Rolling-Months/m-p/1859427#M70933</guid>
      <dc:creator>alex-wb</dc:creator>
      <dc:date>2021-11-15T15:10:14Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative Rolling Months</title>
      <link>https://community.qlik.com/t5/App-Development/Cumulative-Rolling-Months/m-p/1859607#M70939</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Thanks for the questions and discussion and thanks for the updated code&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/2751"&gt;@vinieme12&lt;/a&gt;., I hadn't seen these kinds of tables used to address this accumulation issue in Qlik so I had a look at some articles on creating AsOf tables including this one from Henric.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.qlik.com/t5/Qlik-Design-Blog/The-As-Of-Table/ba-p/1466130" target="_blank"&gt;https://community.qlik.com/t5/Qlik-Design-Blog/The-As-Of-Table/ba-p/1466130&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;It's a great tool for the toolbelt of future requirements.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I did make an error in my initial code which resulted in a large table being generated. I should have created the temp table of distinct monthstart dates first and then entered that in the loop. The result is the exact same table as&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/2751"&gt;@vinieme12&lt;/a&gt;&amp;nbsp;. 35 distinct values and 420 rows. There may be a difference in CPU load between the two different approaches but other than that, the end result is the same.&lt;/P&gt;
&lt;P&gt;temp:&lt;BR /&gt;Load Distinct&lt;BR /&gt;MonthStartDate&lt;BR /&gt;Resident Data;&lt;BR /&gt;&lt;BR /&gt;for i = 0 to 11&lt;BR /&gt;MasterCalendar:&lt;BR /&gt;Load&lt;BR /&gt;month(monthstart(MonthStartDate, $(i))) as RollingMonth,&lt;BR /&gt;monthstart(MonthStartDate, $(i)) as RollingMonthDate,&lt;BR /&gt;MonthStartDate&lt;BR /&gt;Resident temp;&lt;BR /&gt;next i;&lt;/P&gt;
&lt;P&gt;drop table temp;&lt;/P&gt;
&lt;P&gt;Thanks again for the new ideas.&lt;/P&gt;
&lt;P&gt;Anthony&lt;/P&gt;</description>
      <pubDate>Mon, 15 Nov 2021 21:44:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Cumulative-Rolling-Months/m-p/1859607#M70939</guid>
      <dc:creator>anthonyj</dc:creator>
      <dc:date>2021-11-15T21:44:34Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative Rolling Months</title>
      <link>https://community.qlik.com/t5/App-Development/Cumulative-Rolling-Months/m-p/1863547#M71268</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/1157"&gt;@anthonyj&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/2751"&gt;@vinieme12&lt;/a&gt;&amp;nbsp; Quick question regarding how to sort the order of the data. The both codes works great, but I can't order the months correctly, how can I do this?&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 11:28:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Cumulative-Rolling-Months/m-p/1863547#M71268</guid>
      <dc:creator>alex-wb</dc:creator>
      <dc:date>2021-11-25T11:28:12Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative Rolling Months</title>
      <link>https://community.qlik.com/t5/App-Development/Cumulative-Rolling-Months/m-p/1863560#M71270</link>
      <description>&lt;P&gt;Sort by expression&lt;/P&gt;
&lt;P&gt;=Max(MonthStartDate)&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 11:54:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Cumulative-Rolling-Months/m-p/1863560#M71270</guid>
      <dc:creator>vinieme12</dc:creator>
      <dc:date>2021-11-25T11:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative Rolling Months</title>
      <link>https://community.qlik.com/t5/App-Development/Cumulative-Rolling-Months/m-p/1863566#M71271</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/2751"&gt;@vinieme12&lt;/a&gt;&amp;nbsp; Thanks for that. The code you have provided&lt;/P&gt;
&lt;P&gt;Load&lt;BR /&gt;date(FieldValue('MonthStartDate',IterNo())) as RollingMonthDate&lt;BR /&gt;,recno() as r&lt;BR /&gt;AutoGenerate 12&lt;BR /&gt;WHILE len(fieldvalue('MonthStartDate',iterno()));&lt;/P&gt;
&lt;P&gt;NoConcatenate&lt;BR /&gt;AsOf:&lt;BR /&gt;Load&lt;BR /&gt;*&lt;BR /&gt;,Month(RollingMonthDate) as RollingMonth&lt;BR /&gt;,monthstart(RollingMonthDate,1-r) as MonthStartDate&lt;BR /&gt;Resident temp;&lt;BR /&gt;Drop table temp;&lt;BR /&gt;&lt;BR /&gt;Can you use this for multiple fields in one app? And how does this code work?&lt;BR /&gt;Really appreciate the help by the way.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 12:00:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Cumulative-Rolling-Months/m-p/1863566#M71271</guid>
      <dc:creator>alex-wb</dc:creator>
      <dc:date>2021-11-25T12:00:16Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative Rolling Months</title>
      <link>https://community.qlik.com/t5/App-Development/Cumulative-Rolling-Months/m-p/1863572#M71273</link>
      <description>&lt;P&gt;Fieldvalue() works on the field which is stored as a list of unique values in-memory instead of the table rows which is why it is faster.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Len(field value) returns the number of unique values in the field.&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;The while loop simply loops thru the unique values from and&amp;nbsp; Autotgenerate 11 creates 11 rows for each unique value.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;Recno() is simply a record count&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 12:10:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Cumulative-Rolling-Months/m-p/1863572#M71273</guid>
      <dc:creator>vinieme12</dc:creator>
      <dc:date>2021-11-25T12:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative Rolling Months</title>
      <link>https://community.qlik.com/t5/App-Development/Cumulative-Rolling-Months/m-p/1863574#M71274</link>
      <description>&lt;P&gt;Edit and run script without the nested functions and see yourself what each nested function does&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 12:13:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Cumulative-Rolling-Months/m-p/1863574#M71274</guid>
      <dc:creator>vinieme12</dc:creator>
      <dc:date>2021-11-25T12:13:19Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative Rolling Months</title>
      <link>https://community.qlik.com/t5/App-Development/Cumulative-Rolling-Months/m-p/1863582#M71276</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/2751"&gt;@vinieme12&lt;/a&gt;&amp;nbsp; What are the nested functions? I guess if I run the each line individually in the debug script that will work as well?&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 12:29:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Cumulative-Rolling-Months/m-p/1863582#M71276</guid>
      <dc:creator>alex-wb</dc:creator>
      <dc:date>2021-11-25T12:29:01Z</dc:date>
    </item>
  </channel>
</rss>

