Rolling Average of multiple cities

Walterk1

New Member
Joined
Mar 24, 2010
Messages
4
I have looked at MrExcel, OzGrid, and ExcelForums in addition to Googling terms for rolling average. I have seen examples of formulas, and in some cases using Pivot Tables too. I looked at DSUM/D functions, but I was not sure if it would work well. I have not see a good mirror of our issue.

Need: We need to be able to calculate a 12 month rolling Avg based on a selected date. I need to get Avg for multiple sites, based on chosen date.

Summary:
We take data that is downloaded from Lotus Notes DB. The Columns and Rows have been condensed from total dataset. The data appears to be sorted by Site and then Date. The data will continue to grow with time - right now it is 480+ rows, but will grow with time.

Column A - Date, B - Site, C - Hours Worked, D - Accidents.

Some months, we may not have a Site listed. That, along with the order being by site (not date), made me think that I could not rely on X number of rows in my formulas.

I included only 2 sites and only 14 months of data. I calculated the Accident average for the 2 sites by months selected. I will create a date selection input, so when they choose - the averages calculate automatically based on the previous 12 months. (my 1/1/2010 entry means Jan 2009 - Dec 2009 and 2/1/2010 means Feb 2009 - Jan 2010)

I welcome any advice folks may have. I am building this for users I cannot rely to sort by Date/Site (to arrange data). I plan to make a summary sheet that will populate the Running Average based on the month/year they select.


Excel Workbook
ABCDEFGH
1DateSiteTotal Work HoursAccidents****
201/01/09Dallas775,06771*1/1/2010**
301/01/09Atlanta5,9980**Accidents 12 M AvgWork Hours
402/01/09Dallas5,1820*Dallas9.2595,731.75
502/01/09Atlanta67,8340*Atlanta0.7520,685.83
603/01/09Dallas109,83124****
703/01/09Atlanta80,3525*3/1/2010**
804/01/09Dallas127,6081****
904/01/09Atlanta9,9520*Dallas3.4231,998.33
1005/01/09Dallas101,99512*Atlanta0.8321,033.25
1105/01/09Atlanta46,3991****
1206/01/09Dallas1,8180****
1306/01/09Atlanta6,6870****
1407/01/09Dallas4,8130****
1507/01/09Atlanta2,7531****
1608/01/09Dallas2,7360****
1708/01/09Atlanta4,0020****
1809/01/09Dallas10,7213****
1909/01/09Atlanta11,7040****
2010/01/09Dallas1,4090****
2110/01/09Atlanta5,7740****
2211/01/09Dallas4,9520****
2311/01/09Atlanta2,7732****
2412/01/09Dallas2,6490****
2512/01/09Atlanta4,0020****
2601/01/10Dallas10,2661****
2701/01/10Atlanta10,1671****
2802/01/10Dallas1,2660****
2902/01/10Atlanta6,0511****
Sheet1
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
If you have Excel 2007, you could use the AVERAGEIFS function

In cell G4, put this formula to get the 12 month (dates in column A) Average from the date 1/1/2010 (F2), for Dallas (F4) of the data in column D

=AVERAGEIFS(D:D, A:A, "<="&F2, A:A, ">"&Date(Year(F2)-1, Month(F2), Day(F2)), B:B, F4)
 
Upvote 0
Rats - I should have noted that I/we have Excel 2003. :(
I will look at the function and see if there is a way to make a backwards compatible hack.
 
Upvote 0
SUMPRODUCT can SUM based on multiple criteria and COUNT based on multiple criteria. Maybe try something like this in G4

=SUMPRODUCT((A2:A29< =F2)*(A2:A29>DATE(YEAR(F2)-1,MONTH(F2),DAY(F2)))*(B2:B29=F4)*(D2:D29))/
SUMPRODUCT((A2:A29< =F2)*(A2:A29>DATE(YEAR(F2)-1,MONTH(F2),DAY(F2)))*(B2:B29=F4))
 
Last edited:
Upvote 0
cool - I will try the Sumproduct route and report back. I was not sure about the Count piece of the puzzle.
Autofilter would not really work - the data is used for other calcs in the file (DSUM) based on criteria. Maybe that might still work, but I want to keep the users from manipulating Autofilter and subtotals.
The file is basically a dump and report from Notes. They will do various charting and summarization of data, and I do not think I could get it all and train them to manage the file - cleanly.
 
Upvote 0
SOLVED Re: Rolling Average of multiple cities

I just wanted to say thanks to AlphaFrog - I was able to transfer the sumproduct example to my data set, along with a dynamic named range (to compensate for increasing data).
This nailed it on the head! I had read about sumproduct previously, but did not "see the light".
Thanks again.
 
Upvote 0

Forum statistics

Threads
1,224,514
Messages
6,179,219
Members
452,895
Latest member
BILLING GUY

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top