A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Prior 3 Mo Avg Function



 
 
Thread Tools Display Modes
  #1  
Old January 17th, 2010, 06:13 AM posted to microsoft.public.access.queries
cru
external usenet poster
 
Posts: 10
Default 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  
Old January 17th, 2010, 07:14 AM posted to microsoft.public.access.queries
Allen Browne
external usenet poster
 
Posts: 11,706
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:11 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.