Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Rolling Sum

I have a table with two columns.  They are MONTHYEAR (dimension) and a measure, which is really a variable, called TTF_13.  I'm trying to add a third column which will be a 12-month sum for each row.  It is not a rolling sum only of what is displaying in the table, it should be the sum of the prior 12 months up until the month pertaining to the current row.  I've tried both of these approaches but am having no success:

RangeSum(Above(Sum({<MonthYear>}TTF_13),0,12))

and

Sum({<MonthYear={">=$(=Date(AddMonths(Max(MonthYear), -12)))<=$(=Date(Max(MonthYear)))"}>}TTF_13)

In each case, only zeroes are displaying.  Any ideas on what I'm doing wrong?  

Note: This is actually a chart object where the chart type is a straight table.

 Thank you so much for your time!

5 Replies
Gysbert_Wassenaar

Perhaps this documents helps: https://community.qlik.com/t5/QlikView-Documents/Calculating-rolling-n-period-totals-averages-or-oth...


talk is cheap, supply exceeds demand
BI
Partner - Contributor
Partner - Contributor

HI,
It depends on the variable value, if it is straight field then can use below Expression
RangeSum(Above(Sum({<MonthYear>} $(TTF_13)),0,12))

Anonymous
Not applicable
Author

Thanks for the suggestion.  Your suggestion simply results in a dash being displayed for each row.  However, if I do this:

RangeSum(Above(Sum({<MonthYear>} TTF_13),0,12))

...it results in zeroes.  Any other thoughts?

Anonymous
Not applicable
Author

Yeah, I read that which lead me to try this:

RangeSum(Above(Sum({<MonthYear>}TTF_13),0,12))

 ...but it's not working as expected.

Gysbert_Wassenaar

As I explained in the document I linked to the rangesum(above(...)...) construction can only calculate with the data shown in your chart/table. You want to calculate using data that's not shown in the table as well. And therefore you need to use one of the other two options. The sum(aggr(rangesum(above(...)...), MonthYear)) variant or the As-Of table.


talk is cheap, supply exceeds demand