If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Prior 3 Mo Avg Function
I am trying to find easier way to calculate prior 3 mo average. Currently, I
am doing the manual calculation in Excel after importing from Access. I would like to calculate in Access. In the table, I want to calculate period 12/31/2009 where I need the 3mo average of the prior 3 mo count. I wonder if there is a function that can say for current month what is the prior 2 mo avg (counting the current period) PERIOD COUNT 3-MO AVG 10/31/2009 1000 11/30/2009 2000 12/31/2009 3000 2000 Your help is appreciated! Cru |
#2
|
|||
|
|||
Prior 3 Mo Avg Function
Use a subquery to get the 3-month average.
This kind of thing: SELECT [Period], [Count], (SELECT Average([Count] AS AvgCount FROM Table1 AS Dupe WHERE Dupe.[PERIOD] Between DateAdd(m, -2,Table1.[Period]+1) And Table1.[Period])) AS Avg3Month FROM Table1; If subqueries are new, here's an intro: http://allenbrowne.com/subquery-01.html Note that it would be wise to avoid reserved names like Count for your fields. Here's a list: http://allenbrowne.com/Ap****ueBadWord.html -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "cru" wrote in message ... I am trying to find easier way to calculate prior 3 mo average. Currently, I am doing the manual calculation in Excel after importing from Access. I would like to calculate in Access. In the table, I want to calculate period 12/31/2009 where I need the 3mo average of the prior 3 mo count. I wonder if there is a function that can say for current month what is the prior 2 mo avg (counting the current period) PERIOD COUNT 3-MO AVG 10/31/2009 1000 11/30/2009 2000 12/31/2009 3000 2000 Your help is appreciated! Cru |
Thread Tools | |
Display Modes | |
|
|