Prior 3 Mo Avg Function

C

cru

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
 
A

Allen Browne

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top