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: 
paulaoshea
Contributor II
Contributor II

Rolling 6 Month Count

Hi All,

I've looked at previous posts on how to calculate rolling n month aggregations but still can't seem to get this to work for my scenario. I want to add a column to the below that calculates the sum complaints for the previous 6 months. So in Jan 2021 I would want total complaints for the previous 6 months (even though they are not displayed in the table)

paulaoshea_1-1639124760755.png

My rolling 6 month sum is 

=Count({<CREATED_MONTH={">=$(=MonthStart(AddMonths(Max(CREATED_MONTH),-6)))<=$(=MonthEnd(AddMonths(Max(CREATED_MONTH),-1)))"}>}COMPLAINT_ID)

But this obviously is wrong! Any help greatly appreciated,

Thanks.

3 Replies
anat
Master
Master

=sum({<date={">=$(=addmonths(max(date),-6))<=$(=max(date))"}>}[RowNo()])

use dimension as month and above as expression

anat
Master
Master

RangeSum(Above(sum({<date={">=$(=addmonths(max(date),-6))<=$(=max(date))"}>}[RowNo()]),0,7))

paulaoshea
Contributor II
Contributor II
Author

Hi Anat,

thanks for the prompt reply. None of those solutions produce the desired result for me:

paulaoshea_0-1639135924317.png

 

Rolling6_1:

=COUNT({<CREATED_DATE={">=$(=addmonths(max(CREATED_DATE),-6))<=$(=max(CREATED_DATE))"}>} COMPLAINT_ID)

Rolling6_2:

=RangeSum(Above(sum({<CREATED_DATE={">=$(=addmonths(max(CREATED_DATE),-6))<=$(=max(CREATED_DATE))"}>}RowNo()),0,7))

Could it perhaps be that in my table Period is defined in the load script as MonthName(CREATED_DATE)