Results 1 to 4 of 4
  1. #1
    DDEB is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    May 2012
    Posts
    7

    Query to show averages by month

    I'm trying to setup a query that will return the average of a column by month. The table that I'm using for my query has a column called "Call Date" which is in the format dd/mm/yyyy, and I need it to stay in this format in the table. Right now when I run the query I'm getting the average of each column on a daily basis. Is there anyway to get the average of each column on a monthly basis?



    Thanks!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Need to extract the month/year by expression in a calculated field of query then use that field for the grouping.

    MoYr: Format(Month([Call Date]),"00") & Year([Call Date])
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    DDEB is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    May 2012
    Posts
    7
    That worked, thanks!

    I now need to create a parameter query so I can specify which month/year to pull the data for. The criteria I tried using was: Month([Call Date])=[Choose a month from 1-12] And Year([Call Date])=[Choose a year] however I got an error message that said "You tried to execute a query that does not include the specified expression ... as part of an aggregate function." I then tried substituting "MoYr: Format(Month([Call Date]),"00") & Year([Call Date])" for the "Call Date" in the criteria, which also gave me an error message. Any suggestions?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    I NEVER use query parameter prompts - can't validate user input. I have user enter critieria on form and query refers to control on form or use VBA to build WHERE argument of DoCmd.OpenForm (or OpenReport).

    Show the full query statement for analysis. Needs to be something like:

    SELECT Avg([data field to summarize]), Format(Month([Call Date]),"00") & Year([Call Date]) As MoYr FROM table WHERE Month([Call Date]),"00") & Year([Call Date]) = [Enter month 1-12] & [Enter Year as yyyy] GROUP BY Format(Month([Call Date]),"00") & Year([Call Date]);
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. One MS Access Query - Multiple Averages?
    By ajcke in forum Queries
    Replies: 9
    Last Post: 05-09-2012, 07:16 AM
  2. show records in this month last year?
    By geoffcox in forum Queries
    Replies: 4
    Last Post: 06-11-2011, 07:12 AM
  3. Show revenue by month problem
    By TheOmniJuggler in forum Queries
    Replies: 3
    Last Post: 04-15-2011, 10:11 PM
  4. Replies: 2
    Last Post: 03-26-2011, 02:43 PM
  5. Query showing averages for groups
    By AnthonyTesta in forum Queries
    Replies: 1
    Last Post: 02-03-2010, 09:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums