<?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: Aggregating/grouping by four rolling weeks in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Aggregating-grouping-by-four-rolling-weeks/m-p/405185#M699521</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thank you for your try, but I must admit it is not working.&lt;/P&gt;&lt;P&gt;And I am not able to even tell what is wrong, the buckets are just so randomly assigned to the weeks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;May I ask you about the floor function you are using?&lt;/P&gt;&lt;P&gt;I did a bit of research, and it is about rounding down basically. It is not clear to me the purpose, as when you are subtracting two dates, you always have an integer anyway...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;===&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EDIT: I think I'm grasping the purpose of the floor function, it is to attribute an integer to the BUCKET number! &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 05 Dec 2012 18:43:01 GMT</pubDate>
    <dc:creator />
    <dc:date>2012-12-05T18:43:01Z</dc:date>
    <item>
      <title>Aggregating/grouping by four rolling weeks</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregating-grouping-by-four-rolling-weeks/m-p/405177#M699513</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a script which is grouping, by yearly week, sales per product.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13546327218879041" jivemacro_uid="_13546327218879041"&gt;&lt;P&gt;LOAD ONLY(CalendarWeekOfYear) as WeekDemand,&lt;/P&gt;&lt;P&gt;ICSKU,&lt;/P&gt;&lt;P&gt;Sum(LQORD) as WeekQtyOrd&lt;/P&gt;&lt;P&gt;RESIDENT Orders&lt;/P&gt;&lt;P&gt;GROUP BY CalendarWeekOfYear, ICSKU;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to obtain also, a sum of the 4 weeks before, and the 4 before and so on, in other words:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Today, week0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Groups:&lt;/P&gt;&lt;P&gt;week -1 &amp;gt; week -4&lt;/P&gt;&lt;P&gt;week -5 &amp;gt; week -8&lt;/P&gt;&lt;P&gt;week -9 &amp;gt; week -12&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;etc.etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a simple way to achieve this in the script?&lt;/P&gt;&lt;P&gt;Maybe with rangesum and before?&lt;/P&gt;&lt;P&gt;I have been browsing a bit about aggregated sums, but I couldn't find any hint about grouping a rolling bucket of &lt;EM&gt;n&lt;/EM&gt; weeks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Dec 2012 15:05:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregating-grouping-by-four-rolling-weeks/m-p/405177#M699513</guid>
      <dc:creator />
      <dc:date>2012-12-04T15:05:20Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregating/grouping by four rolling weeks</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregating-grouping-by-four-rolling-weeks/m-p/405178#M699514</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;what is the range of the data? only year&amp;nbsp; 2012 ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Dec 2012 19:00:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregating-grouping-by-four-rolling-weeks/m-p/405178#M699514</guid>
      <dc:creator />
      <dc:date>2012-12-04T19:00:17Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregating/grouping by four rolling weeks</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregating-grouping-by-four-rolling-weeks/m-p/405179#M699515</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i hope this will help You.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD ICSKU,&lt;/P&gt;&lt;P&gt;floor((week(today())-CalendarWeekOfYear)/4) as group,&lt;/P&gt;&lt;P&gt;Sum(LQORD) as WeekQtyOrd&lt;/P&gt;&lt;P&gt;RESIDENT Orders&lt;/P&gt;&lt;P&gt;GROUP BY floor((week(today())-CalendarWeekOfYear)/4, ICSKU;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Dec 2012 19:08:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregating-grouping-by-four-rolling-weeks/m-p/405179#M699515</guid>
      <dc:creator />
      <dc:date>2012-12-04T19:08:08Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregating/grouping by four rolling weeks</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregating-grouping-by-four-rolling-weeks/m-p/405180#M699516</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thank you for your input, but is not working as expected.&lt;/P&gt;&lt;P&gt;I am returned just one value, and I can't understand to which range of weeks this single value is referrng to.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Moreover (but that happened many other times in my short QV scripting experience!) I can't figure out how your script should yield my requirement...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Big thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Dec 2012 12:45:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregating-grouping-by-four-rolling-weeks/m-p/405180#M699516</guid>
      <dc:creator />
      <dc:date>2012-12-05T12:45:38Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregating/grouping by four rolling weeks</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregating-grouping-by-four-rolling-weeks/m-p/405181#M699517</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure how to do in the script, but this post was helpful in allowing me tpo do within a chart:&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" class="loading active_link" href="https://community.qlik.com/thread/38355" title="http://community.qlik.com/thread/38355"&gt;http://community.qlik.com/thread/38355&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Jonathan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Dec 2012 13:00:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregating-grouping-by-four-rolling-weeks/m-p/405181#M699517</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-12-05T13:00:50Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregating/grouping by four rolling weeks</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregating-grouping-by-four-rolling-weeks/m-p/405182#M699518</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;post small sample of orders table (f.ex. in qvd or xls)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Dec 2012 13:31:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregating-grouping-by-four-rolling-weeks/m-p/405182#M699518</guid>
      <dc:creator />
      <dc:date>2012-12-05T13:31:47Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregating/grouping by four rolling weeks</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregating-grouping-by-four-rolling-weeks/m-p/405183#M699519</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you again for your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I attached a sample made in Excel.&lt;/P&gt;&lt;P&gt;I'm trying to obtain what you can see in the last column, highlighted.&lt;/P&gt;&lt;P&gt;Of course, for each date there are hundreds of line in my Orders table (in the sample just one per day), and I need to keep the ICSKU details.&lt;/P&gt;&lt;P&gt;Every new week it will need to change the reference interval, as the weeks are passying by.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the moment being, 6 buckets of 28 days will do.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was thinking of someting in this direction:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13547233691445434" jivemacro_uid="_13547233691445434"&gt;&lt;P&gt;WeekEnd(DateInterpret, -1) - WeekStart(DateInterpret, -4)&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But got kinda stuck.&lt;/P&gt;&lt;P&gt;thank you again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Dec 2012 16:02:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregating-grouping-by-four-rolling-weeks/m-p/405183#M699519</guid>
      <dc:creator />
      <dc:date>2012-12-05T16:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregating/grouping by four rolling weeks</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregating-grouping-by-four-rolling-weeks/m-p/405184#M699520</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD ICSKU, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; qty, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; date, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WEEK,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; floor((Week(Date#(date,'YYYYMMDD'))-week(today())-4)/4)+1 as BUCKET&lt;/P&gt;&lt;P&gt;FROM&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Dec 2012 16:57:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregating-grouping-by-four-rolling-weeks/m-p/405184#M699520</guid>
      <dc:creator />
      <dc:date>2012-12-05T16:57:09Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregating/grouping by four rolling weeks</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregating-grouping-by-four-rolling-weeks/m-p/405185#M699521</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thank you for your try, but I must admit it is not working.&lt;/P&gt;&lt;P&gt;And I am not able to even tell what is wrong, the buckets are just so randomly assigned to the weeks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;May I ask you about the floor function you are using?&lt;/P&gt;&lt;P&gt;I did a bit of research, and it is about rounding down basically. It is not clear to me the purpose, as when you are subtracting two dates, you always have an integer anyway...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;===&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EDIT: I think I'm grasping the purpose of the floor function, it is to attribute an integer to the BUCKET number! &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Dec 2012 18:43:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregating-grouping-by-four-rolling-weeks/m-p/405185#M699521</guid>
      <dc:creator />
      <dc:date>2012-12-05T18:43:01Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregating/grouping by four rolling weeks</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregating-grouping-by-four-rolling-weeks/m-p/405186#M699522</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;actually, this simple script is working for me&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13547348166363711" jivemacro_uid="_13547348166363711"&gt;&lt;P&gt;LOAD ICSKU, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LQORD as BucketQty, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DateInterpret as BucketDate, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; floor((Week(DateInterpret)-week(Today()))/4) as BUCKET&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Easy peasy! &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now the next big challenge is how to distinguis the weeks of different year, as, for example, in Bucket -1, besides the correct dates (20121105 - 20121202), it is including 20131113, so that would be the -1 bucket for the same week# of next year. This seems more difficult to tackle, as qlikview can't handle a&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Year(Date)&amp;amp;Week(Date)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...I think...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and anyway is going to become tricky also with the beginning of the new year, when bucket -1 will be, e.g., equal to weeks 2,1,52,51.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Dec 2012 19:13:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregating-grouping-by-four-rolling-weeks/m-p/405186#M699522</guid>
      <dc:creator />
      <dc:date>2012-12-05T19:13:13Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregating/grouping by four rolling weeks</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregating-grouping-by-four-rolling-weeks/m-p/405187#M699523</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I manged with the following script&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13547421355304737" jivemacro_uid="_13547421355304737"&gt;&lt;P&gt;LOAD ICSKU, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Qty as BucketQty, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DateInterpret as BucketDate, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; floor((((DateInterpret)-WeekStart(today(), -1))-7)/28) as BUCKET&lt;/P&gt;&lt;P&gt;RESIDENT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This way, a bucket of 4 weeks counting back from the last Sunday(included) is created and it works fine over the transition to the new year! &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Dec 2012 21:16:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregating-grouping-by-four-rolling-weeks/m-p/405187#M699523</guid>
      <dc:creator />
      <dc:date>2012-12-05T21:16:29Z</dc:date>
    </item>
  </channel>
</rss>

