# Re: Rolling Calculations

• From: Harlan Grove <hrlngrv@xxxxxxx>
• Date: Wed, 05 Sep 2007 17:13:29 -0700

I have a spread sheet with three years of monthly data. I need to
calculate for a rolling twelve month total each month.
(i.e.)
sum data in columns for (Jan2006 - Dec2006),
sum data in columns for (Feb2006. - Jan2007),
sum data in columns for (Mar2006. - Feb2007, etc.)
....

How are the months identified? Is the data grouped by year in fixed
size chunks, e.g., each month's data spans 20 rows? Is there another
column with dates?

If column A contained dates and column B the data you want to sum,
both spanned rows 1 to 10000, and if Jan2006 thru Dec2006 were the
first 12 month period to sum, then try the following.

D1:
=SUMIF(A\$1:A\$10000,">="&DATE(2006,ROWS(D\$1:D1),1),B\$1:B\$10000)
-SUMIF(A\$1:A\$10000,">="&DATE(2007,ROWS(D\$1:D1),1),B\$1:B\$10000)

Fill D1 down into D2:D36. Another alternative, shorter, more efficient
but also more complex, would be

D1:
=SUMPRODUCT(--(ABS(12*(2006-YEAR(A\$1:A\$10000))+5.5
-MONTH(A\$1:A\$10000)+ROWS(D\$1:D1))<6),B\$1:B\$10000)

which you'd also fill down into D2:D36.

.