Solved

Calculating monthly averages

Posted on 2015-02-10
4
91 Views
Last Modified: 2015-02-18
Hello,

I've written the following code that displays the daily difference between two dates of the NE_Percent_Avail_Daily field via this portion of the code.  I'm now trying to figure out how to display the average of all the values of the NE_Percent_Daily field for each month and display that value in the first entry for that month in a calculated field.  The number of entries in a month can vary.

[NE_Percent_Avail_Daily]-(select NE_Percent_Avail_Daily from SummaryTable where NE_Entry_Date =
(select max(NE_Entry_Date) from SummaryTable where NE_Entry_Date < S.NE_Entry_Date)) AS NEDailyChange,

SELECT S.NE_Entry_Date, S.NE_Items, S.NE_Items_Avail, S.NE_Percent_Avail_Daily, [NE_Percent_Avail_Daily]-(select NE_Percent_Avail_Daily from SummaryTable where NE_Entry_Date =
(select max(NE_Entry_Date) from SummaryTable where NE_Entry_Date < S.NE_Entry_Date)) AS NEDailyChange, S.NE_Percent_Avail_MTD, S.NE_Monthly_Change, S.NE_Percent_Avail_Yearly, S.NE_YTD_Change, S.ColumnSpace1, S.LTN_Entry_Date, S.LTN_NE_ITEMS, S.LTN_Avail, S.LTN_Percent_Avail_Daily, [LTN_Percent_Avail_Daily]-(select LTN_Percent_Avail_Daily from SummaryTable where LTN_Entry_Date =
(select max(LTN_Entry_Date) from SummaryTable where LTN_Entry_Date < S.LTN_Entry_Date)) AS LTNDaily_Change, S.LTN_Percent_Avail_MTD, S.LTN_Monthly_Change, S.LTN_Percent_Avail_YTD, S.LTN_YTD_Change, S.ColumnSpace2, S.QRO_Entry_Date, S.QRO_Items, S.QRO_Avail, S.QRO_Percent_Avail_Daily, [QRO_Percent_Avail_Daily]-(select QRO_Percent_Avail_Daily from SummaryTable where QRO_Entry_Date =
(select max(QRO_Entry_Date) from SummaryTable where QRO_Entry_Date < S.QRO_Entry_Date)) AS QRODaily_Change, S.QRO_Percent_Avail_MTD, S.QRO_Monthly_Change, S.QRO_Percent_Avail_YTD, S.QRO_YTD
FROM SummaryTable AS S
ORDER BY S.NE_Entry_Date;

Open in new window

0
Comment
Question by:chtullu135
  • 2
4 Comments
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
Comment Utility
Are you saying that you want a running average, which would give you the average of the previous X (maybe 30) days for every date in a sequence?  Or that you simply want the 12 monthly averages?

Can you provide an example of what the output would look like?
0
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 500 total points
Comment Utility
You can use an expression like:

MonthAverage: IIf(Day(S.NE_Entry_Date)>1, Null, DAvg("YourAmountField","YourQuery","YourDateCriteria"))

/gustav
0
 

Author Closing Comment

by:chtullu135
Comment Utility
Thanks Gustav.  I 'm sorry for the delay in replying but for some reasons, I can't post my replies from my computer at work and my closing of questions did not go through.
0
 
LVL 49

Expert Comment

by:Gustav Brock
Comment Utility
You are welcome!

/gustav
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now