Monthly year to date average

I have scores for given records for a particular date:

3/15/07  67
4/1/07   43
1/15/07  56

I would like to be able to average these scores by month, but have a running 
total:

January 56
February 56
March  61.5 (average 56 & 67)
April   55.3  (average 56, 67, and 43)

I think I need to use a DAvg function, but it isn't working yet.
0
Utf
4/12/2007 12:42:01 PM
access.queries 6343 articles. 1 followers. Follow

3 Replies
1389 Views

Similar Articles

[PageSpeed] 5

*IF*  you have only ONE record per month, you can try:


SELECT  a.date, LAST(a.qty), AVG(b.qty)
FROM tableName As a INNER JOIN tableName As b
    ON a.date >= b.date
GROUP BY a.date



that would give:

1/15/2007    56    56
3/15/2007    67    61.5
4/1/2007      43    53.3



you can then format the first column as:   Format( fieldName, "yyyy mmm") :

    ? Format(now, "yyyy mmm")
    2007 Apr


You can replace LAST by SUM, MAX, MIN, FIRST, ... since, anyhow, it operates 
on a single row, HERE, that does not really matter, as long as there is an 
aggregate.

If there is no record for a given month (no record for February), it won't 
appear in the result.



Hoping it may help,
Vanderghast, Access MVP


"Stumped" <Stumped@discussions.microsoft.com> wrote in message 
news:0ECDFEFB-8EF4-4599-8E1F-76173FC842D3@microsoft.com...
>I have scores for given records for a particular date:
>
> 3/15/07  67
> 4/1/07   43
> 1/15/07  56
>
> I would like to be able to average these scores by month, but have a 
> running
> total:
>
> January 56
> February 56
> March  61.5 (average 56 & 67)
> April   55.3  (average 56, 67, and 43)
>
> I think I need to use a DAvg function, but it isn't working yet. 


0
Michel
4/12/2007 1:43:34 PM
Unfortunately, I have several entries per month, and sometimes no 
entries...any ideas?

"Michel Walsh" wrote:

> *IF*  you have only ONE record per month, you can try:
> 
> 
> SELECT  a.date, LAST(a.qty), AVG(b.qty)
> FROM tableName As a INNER JOIN tableName As b
>     ON a.date >= b.date
> GROUP BY a.date
> 
> 
> 
> that would give:
> 
> 1/15/2007    56    56
> 3/15/2007    67    61.5
> 4/1/2007      43    53.3
> 
> 
> 
> you can then format the first column as:   Format( fieldName, "yyyy mmm") :
> 
>     ? Format(now, "yyyy mmm")
>     2007 Apr
> 
> 
> You can replace LAST by SUM, MAX, MIN, FIRST, ... since, anyhow, it operates 
> on a single row, HERE, that does not really matter, as long as there is an 
> aggregate.
> 
> If there is no record for a given month (no record for February), it won't 
> appear in the result.
> 
> 
> 
> Hoping it may help,
> Vanderghast, Access MVP
> 
> 
> "Stumped" <Stumped@discussions.microsoft.com> wrote in message 
> news:0ECDFEFB-8EF4-4599-8E1F-76173FC842D3@microsoft.com...
> >I have scores for given records for a particular date:
> >
> > 3/15/07  67
> > 4/1/07   43
> > 1/15/07  56
> >
> > I would like to be able to average these scores by month, but have a 
> > running
> > total:
> >
> > January 56
> > February 56
> > March  61.5 (average 56 & 67)
> > April   55.3  (average 56, 67, and 43)
> >
> > I think I need to use a DAvg function, but it isn't working yet. 
> 
> 
> 
0
Utf
4/12/2007 2:42:02 PM
You can do that using two queries
1. Sum Per month

SELECT Month([DateField]) AS MyMonth, Year([DateField]) AS MyYear, 
Sum(TableName.scores) AS SumOfScore
FROM TableName
GROUP BY Month([DateField]), Year([DateField])

2. The Avg and accumlative query based on the first query

SELECT MyQueryName.MyYear, MyQueryName.MyMonth, 
DSum("SumOfScore","MyQueryName","MyMonth <=" & [MyMonth] & "  And MyYear<=" & 
[MyYear]) AS RunningSum, MyQueryName.SumOfScore, 
DAvg("SumOfScore","MyQueryName","(MyMonth <=" & [MyMonth] & "  And MyYear=" & 
[MyYear] & ") Or MyYear < " & [MyYear]) AS MonthAvg
FROM MyQueryName
ORDER BY MyQueryName.MyYear, MyQueryName.MyMonth

-- 
Good Luck
BS"D


"Stumped" wrote:

> Unfortunately, I have several entries per month, and sometimes no 
> entries...any ideas?
> 
> "Michel Walsh" wrote:
> 
> > *IF*  you have only ONE record per month, you can try:
> > 
> > 
> > SELECT  a.date, LAST(a.qty), AVG(b.qty)
> > FROM tableName As a INNER JOIN tableName As b
> >     ON a.date >= b.date
> > GROUP BY a.date
> > 
> > 
> > 
> > that would give:
> > 
> > 1/15/2007    56    56
> > 3/15/2007    67    61.5
> > 4/1/2007      43    53.3
> > 
> > 
> > 
> > you can then format the first column as:   Format( fieldName, "yyyy mmm") :
> > 
> >     ? Format(now, "yyyy mmm")
> >     2007 Apr
> > 
> > 
> > You can replace LAST by SUM, MAX, MIN, FIRST, ... since, anyhow, it operates 
> > on a single row, HERE, that does not really matter, as long as there is an 
> > aggregate.
> > 
> > If there is no record for a given month (no record for February), it won't 
> > appear in the result.
> > 
> > 
> > 
> > Hoping it may help,
> > Vanderghast, Access MVP
> > 
> > 
> > "Stumped" <Stumped@discussions.microsoft.com> wrote in message 
> > news:0ECDFEFB-8EF4-4599-8E1F-76173FC842D3@microsoft.com...
> > >I have scores for given records for a particular date:
> > >
> > > 3/15/07  67
> > > 4/1/07   43
> > > 1/15/07  56
> > >
> > > I would like to be able to average these scores by month, but have a 
> > > running
> > > total:
> > >
> > > January 56
> > > February 56
> > > March  61.5 (average 56 & 67)
> > > April   55.3  (average 56, 67, and 43)
> > >
> > > I think I need to use a DAvg function, but it isn't working yet. 
> > 
> > 
> > 
0
Utf
4/12/2007 6:34:00 PM
Reply:

Similar Artilces:

Document Date vs. Batch Date
Can someone explain to me the difference between document date and batch date. The way I understand it, the document date refers to the date the item will hit the subledger and the batch date (if batch date is the posting option) refers to the date the transaction will hit the general ledger. Is this correct? Does this mean that if I have all my periods open for a year and I enter a cash receipt transaction with a document date of 05/01/04 in a batch with a batch date of 06/01/04 that my subledger will not balance to my general ledger for that month? Elizabeth, You've got it ...

DATE #10
Feb 28,2008 ---> 2008-2-28 Feb 1,2008 ---> 2008-2-1 Format? "����" <cola@hz.cn> wrote in message news:OOQhTbRaKHA.5472@TK2MSFTNGP02.phx.gbl... > Feb 28,2008 ---> 2008-2-28 > Feb 1,2008 ---> 2008-2-1 > See your other post "ÎÞÃû" wrote: > Feb 28,2008 ---> 2008-2-28 > Feb 1,2008 ---> 2008-2-1 > > > . > Hi, Highlight the cell, right click in the mouse, cell format, custom format and enter yyyy-mm-dd "ÎÞÃû" wrote: > Fe...

Bank Rec void check date s/b same as GL void date
When voiding a check in the payables management module and the Void date and Posting date are changed from the original check date, Bank reconciliation should recognize that void date instead of the original check date as the voided date. Please refer to Knowledgebase Article 857704 to see how Ban Rec handles the date of a void check. If a check is voided in Payables Mgmt on a different date than the original date, and bank rec uses the original date trying to reconcile to the general ledger is a problem because the adjusted bank book balance is different than the GL balance becuase th...

Calendar Formatting Date Range problem
Hi, I am trying to make a monthly calendar that our administrator can update easily with new dates, and mail out. I've formatted the calendar and it looks great as it is right now for the month of April. However, when I choose "change date range" it reverts back to the original formatting and I have to start all over. I realize this is because I used a "design object". However, if I don't use a design object, then I can't change the date ranges. How do I change the date range on my calendar without losing all the formatting changes I made? Thanks T...

Can I set up a calendar lookup for date selection
Is it possible to lookup a calendar for date selection on a cell. I cannot find any reference to it in the help. try this url http://www.fontstuff.com/vba/vbatut07.htm ================= "Tangoxray" <Tangoxray@discussions.microsoft.com> wrote in message news:72D4DB63-1D7F-477A-93C7-2F767A207B26@microsoft.com... > Is it possible to lookup a calendar for date selection on a cell. I cannot > find any reference to it in the help. ...

Can you automatically date stamp emails that you send out? #2
My emails need a date stamp on them as I send them. It does not appear that you can do this..does someone have an idea to do this? Thanks ...

Copying dates between Excel documents
I have noticed that when I copy a date eg/ 23/02/04 (UK format) from on Excel document to another the date becomes 22/02/00. Has anyone comes across this, its really infuriating as I have t redate everything again Thank -- Message posted from http://www.ExcelForum.com XL has two date systems, the Windows default 1900 date system, in which the 0-base date is 31 December 1899, and the MacXL default 1904 date system, in which the 0-base date is 1 January 1904. The systems differ by 4 years and a day. To resolve your issue, make sure that both workbooks have the same date system selected...

Change Order date?
I have situation where we had to enter some orders into CRM like 3 weeks after the fact but there was no way to to back date them when entering so that they fall into the proper months reports, etc. Any help out there on how I can change the dates at the database level? Look in the SalesOrderBase table. Mike "SteveT" <drumguy61-google@yahoo.com> wrote in message news:4635de59.0402120638.1bd39e41@posting.google.com... > I have situation where we had to enter some orders into CRM like 3 > weeks after the fact but there was no way to to back date them when > entering ...

Help Please- How to offset Date to correct column for Ageing
Hi All, I have a stock ageing sheet for finished goods, which uses a vlookup table, on entry of the Product code (last 3 Digits), this populates the next three columns with description, FG cost and Quantity of product. the quantity of product is entered again manually into the appropriate column, there are five columns these are banded <3 Months 0%, 3 to 6 Months 25%, 6 to 9 months 50%, 9 to 12 Months 75% and > 1 Year 100%, the percentage is liability provision. What I would like to do is on entry of the product code as above the quantity is automatically inserted into the correc...

Can't get Date Range to work from Form to Report
Hi, I've followed Allen Browne's directions very closely for creating a form for a date range to limit results to that date range on a report and can not get it to work for some reason. I've read many threads on this board which all say the same thing and it seems to work for everyone else. :( Here's what I have: A form with two unbound text boxes called [txtDateBegin] and [txtDateEnd]. The form is called "frmDateRange" and the report is called "Sales Activity Report". The two unbound text boxes are set to "Short Date" format which the user ...

Publisher 97 and date/time print
I am designing an office card using 1997 Publisher. No matter what I do it prints day, month,year and time on every page. I have checked background and there is no text box even there to delete to stop this problem. How can I find and delete? This will be an option of your printer driver. Disable that option and your trauma will be over. -- ...

Dollar and date format
I have 2 questions related to formatting information that I have imported: 1)If I have a column that contains amounts such as 0000000427.99 and I want to remove the decimal but keep the trailing cents, what is the best way to do that for a whole column? example: 000000042799 2) I also have a date that has been imported as 3/9/2005 and I need to remove the "/"'s and have the month and date format with zeros if needed such as 03092005, what is the best way to accomplish this on a column. Thank you, Rick For Question # 1 - Multiply by 100 :-)) Just kidding For Question # ...

Calculating dates & creating reports
I need to design a database that will calculate due dates for evaluations. It will have 5 dates. 4 are calculated. These dates need to be on a form along with the employee's name and other vital info. The user should be able to enter that Start Date and have all the other dates calculate automatically. There are approximately 55 employees! The first date (Start Date) is entered by the user. Example: User enters Start Date: 2/01/07. #2 Next Date is 91 days from 2/1/07, which calculates to 5/03/07. #3 Six Month Date is 182 days from Start Date, which calculates to 8/02...

Report to Filter on Next Date Per File
I have a docketing report which reports any action due for a particular file. Theses actions are future dates. A file can have multiple actions due. For example: File ABC12345 Action 6/1/2010 Letter to Client Action 6/9/2010 Payment Due Action 12/10/2010 Status Check File CYO4457 Action 3/1/2011 Letter re Exam Action 6/4/2011 Annuity Due I need to write a report which will only give me the next action due. Using my example the output would be like the following: File ABC12345 Action 6/1/2010 Letter to Client Fil...

Date sensitive cells
Hello there, I am trying to create a contract management system and would like to input all the relevant data into a spreadsheet. A month before a contract runs out I would like all the data relevant to it to be highlighted or in some way made obvious that the contract is coming to an end and needs the attention of the user. Can anyone help me with this? Thankyou very much Let's say that the expiration date of the contract is in cell B1, and you want all of row 1 to turn red when you are within 30 days of that date. Select row 1, the use format / Conditional formatting, select for...

Home Page Content Item: Important Dates (repost)
I asked this question 3 days ago and have received no replies so I'm repeating it. Perhaps the subject name I used: "Important Dates" was too short or sounded like spam. In any case my experience on this board is that even if no one has a solution, someone usually responds saying that he can't reproduce the problem, or that it doesn't work for him either, or that the poster misunderstands what this function is supposed to do. Not having received any response at all, I beg your indulgence with this repost: ***** Money 2006. No Passport. XP Home SP2. P4 3.0 GHz. 1G...

Getting local Time and date for the local computer(vista OS)
Hi I am working with Vista(one of a kind), and have a MFC application and would like to add small code that will get current time and date from the local compuetr. i meet an example in MSDN : http://msdn.microsoft.com/en-us/library/aa390423(VS.85).aspx but it looks too long for what i am looking, is there a 1 function API that returns the Date and the time ? thanks for your time Zack >Hi I am working with Vista(one of a kind), >and have a MFC application and would like to add small code that will get >current time and date from the local compuetr. >i meet an example in MSDN...

Formula For Monthly Date
Hello, I have a worksheet that has products listed that are on sale at different times of the year. My question is what formula to use to get all Jan products,codes,prices etc on to new worksheet, Feb on another worksheet etc. Thanks Mare Use Autofilter. See: http://www.contextures.com/xlautofilter01.html -- Gary's Student "Mare" wrote: > Hello, > I have a worksheet that has products listed that are on sale at different > times of the year. My question is what formula to use to get all Jan > products,codes,prices etc on to new worksheet, Feb on another works...

day of the week and date formula
Hello I am looking to write a formula that gives me the difference in hours between a logged date and time and a closed date and time eg -27/11/2009 09:23:26 and 30/11/2009 10:34:20. Once I have this I need to calculate the working hours used to resolve the issue. If the duration of the time includes a weekend, a saturday would equate to 4 hours working and a sunday would be 0 hours working time, a week day equates to 11.5 hours working. Any suggestions?? Thanks -- Sarah Hi, we need to know what hours during any day are considered working - ie, do all hours...

Date range in months from month and year fields
In our database we track consultants work dates in four seperate fields, starting month, starting year, ending month, ending year. Is there anyway to calculate the range of months they have worked with this set up? So if someone started March 2004 and ended July 2007 is there a formula to calculate the 40 months they worked? DateDiff("m",[starting month] & "/" & "01" & "/" & [starting year],[ending month] & "/" & "01" & "/" & [ending year]) "monkeycr84" wrote: > In our da...

problem with dates in csv file
Hi, I'm trying to save a .csv file at the moment, the person who I' sending it to needs the dates in 1 column as dd-mmm-yy, eg 18-Sep-05 eg 09-Sep-05. When I save the file it always reverts the dates 09 o below back to a single number, 9 etc. I've tried copying the column into word, paste special as text formatting the column in excel to text and pasting special back in a text, it works ok but when I save and open the file it reverts back! does anyone know how I could get around this? Many thanks, saybut -- saybu --------------------------------------------------------------...

Fixed Assets Import (6 months ago)
Hello: It really is a moot point. The situation is over, my clients are happy, and I am able to import fixed assets just fine. But, six months ago and right before service pack 1 for GP 9.0 was released, for the first time ever I was unable to import fixed assets. The FA Import Tool would show--on the "surface"--that all of my assets imported. But, the fact of the matter was that the assets did NOT import. And, there were no error messages givens to why! I had opened up a case with Microsoft, at that time. They admitted that they could not solve the mystery. And, they s...

formula to return 1st of the month following 60 days
Hello - I need, please, a formula to return the following. So, if someone started working with us on 10/15/09, the 1st of the month following 60 days of employment would be 1/1/10. That's what I need. THANK YOU! What about 1st of a month say 10/1/2009 'If you expect 1/1/10 then use =DATE(YEAR(A1),MONTH(A1)+3,0)+1 'if you expect 12/1/09 then use the below version =DATE(YEAR(A1-1),MONTH(A1-1)+3,0)+1 Regards Jacob "Jessica" wrote: > Hello - > > I need, please, a formula to return the following. So, if someone started > ...

Can't open this item. The end date you entered occurs before the start date.
Hi, Everytime I open Outlook 2000 I get a calender pop-up. When I Dismiss it I get a message such as the above and the next time I open Outlook it appears again. I can't see it in the Calender unless I change the view to "By category". I can't delete it or change the date in this view. I just keep getting the above message (see subject line). I tried /cleanreminders and the MS article about Daylight savings but neither work. How do I get rid of this message? I do have a Pocket PC and probably the error occured during a Sync (i have different time zones). ...

beginning balance historical year
I am entering beginning balances in General Transactions Entry window for the previous year 2003. The year is marked as a historical year and I am using the last day from the historical year as the transaction date. When printing the edit list, the Batch Total Actual is the sum of the debit and credit entries from the source document. When looking at the edit list, all the entries are printed twice, while I have entered them only once, and the total per debit and credit entries also is double. When printing a historical Trial Balance the totals are o.k. Where the double entries are coming...