ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Rolling Calculations (https://www.excelbanter.com/excel-worksheet-functions/157183-rolling-calculations.html)

Motaad

Rolling Calculations
 
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.)

--progressing the total along twelve months each new month. Any ideas
--
Motaad

Don Guillett

Rolling Calculations
 
Put this one line formula in a columndrag to the right two columnsselect
the three formulas and drag to copy down 12 rows

=SUMPRODUCT((YEAR($A$1:$A$400)=COLUMN(A1)+2003)*(M ONTH($A$1:$A$400)=ROW(A1))*$B$1:$B$400)

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Motaad" wrote in message
...
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.)

--progressing the total along twelve months each new month. Any ideas
--
Motaad



Harlan Grove

Rolling Calculations
 
Motaad wrote...
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.



All times are GMT +1. The time now is 11:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com