1 Reply Latest reply: Jul 26, 2012 2:23 AM by Søren Skovsgaard RSS

    Sum last 12 months on load for each month loaded

    Søren Skovsgaard

      Hi

       

      I am pretty new to Qlikview, but have so far found a lot of usefull help by reading old posts - but I have now come to an issue I can't find a solution to, and hope you can help.

       

      I have a set of data that I already using groubp by have aggregated to look something like below.

       

      YearMonthValue
      201141
      201152
      201163
      201174
      201185
      201196
      2011107
      2011118
      2011129
      2012110
      2012211
      2012312
      2012413
      2012514
      2012615

       

      I would like to have each month aggregated even further, so that the value of the month is the sum of the last 12 months, i.e. month 3 year 2012 should have a value of 78 (1+2+3+4+5+6+7+8+9+10+11+12). Likewise month 4 year 2012 should have a value of 90 (2+3+4+5+6+7+8+9+10+11+12+13) etc.

       

      I want this to happen in the load script, so I can store the result as a QVD file to be loaded in other QV apllications. Naturally I have additional dimensions, and this aggregation should work for the other dimensions as well, meaing a last 12 month sum for product A and a last 12 month sum for product B.

       

      I hope the example makes sense and you can provide me with the hints of a solutions, so I in the end can expand it over several countries and also calculated for last 52 weeks.

       

      Regards

      Soren