Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
koushikvutha
Partner - Contributor II
Partner - Contributor II

ROlling 12 Months

hi

Please see attached data. Any method to achieve this in edit script?

1 Solution

Accepted Solutions
5 Replies
Gysbert_Wassenaar

Perhaps this document helps: Calculating rolling n-period totals, averages or other aggregations


talk is cheap, supply exceeds demand
Kushal_Chawda

petter
Partner - Champion III
Partner - Champion III

It can be achieved by using Peek() and three temporary Fields:

LOAD BusinessUnit,
MonthYear,
Value,
Alt( Peek('Value',-11), Null()) AS FirstOne,
Alt( Peek('RunningTotal') , 0) + Value AS RunningTotal,
Alt( Peek('FirstOne') , 0) + Alt(Peek('RunningFirstOne'),0) AS RunningFirstOne,
If( RecNo() > 11 ,Peek('RunningTotal') + Value - Peek('FirstOne') - Peek('RunningFirstOne')) AS Rolling12Months,
F4,
[Expectation - Rolling 12 months],
F,
G,
H,
I
FROM
[12MonthsTest.xlsx]
(
ooxml, embedded labels, table is Sheet1);

DROP FIELDS FirstOne, RunningTotal, RunningFirstOne;

koushikvutha
Partner - Contributor II
Partner - Contributor II
Author

Thanks Gysbert. This was really helpful.

I could achieve it using accumulate but wanted a clever workaround in script.

koushikvutha
Partner - Contributor II
Partner - Contributor II
Author

Perfect. Sorted.

Cheers.