Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Create a rolling 8 months total based on current records date

Dear Community,

Hope you can provide some guidance on how to solve this problem.

My table is strutured as follows

MyDate               Cost of Sales     Rolling 8 months cost of sales

1/15/2012        100                                        ??

2/15/2012        200                                        ??

3/15/2013        300                                        ??

Where ?? is a sum of the current plus previous 8 months Cost of Sales

So Rolling 8 months cost of sales for 3/15/2013 would be 300 + 200 + 100 + 5 periods from the previous year.

I've tried using addmonths with a minus condition and can see how that works in a text box (= AddMonths(Now(), -6))

The problem I have is that if I use MyDate then only the one row is selected.

In my programming world I'd need two loops to solve this

Outer one with unique MyDate Values #A

Inner one to loop through all the records testing the myDate value against #A and #A - 8 periods to accumulate to a new field.

Could be I'm just thinking about this wrong, you assistance greatly appreciated.

Thanks,

Jim

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

See this discussion for how to deal with this kind of problem.


talk is cheap, supply exceeds demand

View solution in original post

2 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

See this discussion for how to deal with this kind of problem.


talk is cheap, supply exceeds demand
Not applicable
Author

Thanks and sorry for the delayed acceptance of your Answer.  The proposed answer was a little complicated initially, but after debugging with small steps I 'mastered' it.