From: cru on
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
From: Allen Browne on
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/AppIssueBadWord.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" <cru(a)discussions.microsoft.com> wrote in message
news:07D0C09B-954E-4633-9EF6-E0B9ADE480AC(a)microsoft.com...
> 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