10 Replies Latest reply: Dec 5, 2012 4:16 PM by Erik Furlanis RSS

    Aggregating/grouping by four rolling weeks

      Dear all,

       

      I have a script which is grouping, by yearly week, sales per product.

       

      LOAD ONLY(CalendarWeekOfYear) as WeekDemand,
      ICSKU,
      Sum(LQORD) as WeekQtyOrd
      RESIDENT Orders
      GROUP BY CalendarWeekOfYear, ICSKU;
      

       

      I would like to obtain also, a sum of the 4 weeks before, and the 4 before and so on, in other words:

       

      Today, week0.

       

      Groups:

      week -1 > week -4

      week -5 > week -8

      week -9 > week -12

       

      etc.etc.

       

      Is there a simple way to achieve this in the script?

      Maybe with rangesum and before?

      I have been browsing a bit about aggregated sums, but I couldn't find any hint about grouping a rolling bucket of n weeks.

       

      Thanks!