7 Replies Latest reply: Oct 12, 2015 3:49 AM by Tresesco B

# Rolling 12 months average in chart

Hi All,

I have the following set expression for rolling 12 months total:

Sum({\$<[Period]={'>=\$(=Monthstart(Max(Period),-11))'}>} [Sales])

It works fine in a KPI box. It returns the sum of the past 12 months with the largest value of [Period] as the start.

However, when i use the same expression in a chart, only the sales for each month is plotted.

What I am looking for is for the chart to show the rolling 12 months total for each data point.

Thanks!

• ###### Re: Rolling 12 months average in chart

What is the value of Period? Is a Date?

• ###### Re: Rolling 12 months average in chart

Yup. It is a Date.

• ###### Re: Rolling 12 months average in chart

Not sure, may be you are talking about accumulation. Try 'Full Accumulation' in the expression tab.

• ###### Re: Rolling 12 months average in chart

Is it possible to do it on Qlik Sense?

I can't seems to find this function.

• ###### Re: Rolling 12 months average in chart

Instead, you could try with rangesum(), like:

rangesum(above(total Sum({\$<[Period]={'>=\$(=Monthstart(Max(Period),-11))'}>} [Sales]),0,Rowno(Total)))

• ###### Re: Rolling 12 months average in chart

Hi Tresesco,

Can you roughly explain what the formula is doing?

I tried looking up the Chart function guide but I do not really understand.

The chart output i get from the formula is a cumulative sum of sales from Dec-2014 to Aug-2014 (My max period) but what I am looking for is the rolling 12 month sum.

For example, the data point for Dec-2014 should be the sum of sales from Jan-2014 to Dec 2014.

I have verified using a pivot table that I did loaded sales data since 2012 into Qlik.

• ###### Re: Rolling 12 months average in chart

Well, not yet sure though. Perhaps you are looking for 12 months aggregation at each month. If so, try like:

sum( aggr( rangesum( above( sum( {\$<Month>}  Sales),0,12) ),Month))

Please refer: Accumulative Sums for better understanding.