Results 1 to 13 of 13
  1. #1
    ctrapper is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Dec 2011
    Posts
    7

    Computing an Average


    I have a list of jobs in one column, with corresponding numeric values in another for given dates. Is there a query I can create that would start with the 5th occurrence, and give me a 5 day average as I move down in dates.. ? does this make sense?

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Are you trying to get an average by week? The function DatePart will give you a week number which you can group by and then get an average of the numbers.

  3. #3
    ctrapper is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Dec 2011
    Posts
    7
    Hi Aytee.. it's more of running 5 day average.. for example.. after the 5th of the month, going forward I want to average only the last 5 days of data.. it could overlap weeks.. I tried doing it in excel... the only way I know for sure to do it is to filter out all 30 jobs into separate tabs, compute tehe 5 day ave, then combine them all back together.. seems like there's an easier way to do it..

  4. #4
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    If you only want the last 5 days - always - then in your criteria for the date column put something like this: >Date()-6 (after today minus 6). I presume you have the date stored?

  5. #5
    ctrapper is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Dec 2011
    Posts
    7
    Ok thanks I will try that.. I am not as versed in Access as I am in EXCEL, but I think Access has more flexibility when dealing with data.. I will give it a try!

  6. #6
    ctrapper is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Dec 2011
    Posts
    7
    Yes Date is posted in the Table in the format 11/7/2010 for example:

    When I enter Criteria as you suggested as: >11/7/2010()-6 I get an error back.. invalid

  7. #7
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    For this type of thing, Excel is far better suited. Access cannot refer to values in any records other than the current one, be it in a recordset, a query, or a form in datasheet view.

    You are right in saying that Access has more flexibility, but it's not Excel, and cannot do everything Excel does.

    John

  8. #8
    ctrapper is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Dec 2011
    Posts
    7
    John I don't disagree at all that's where I started.. I have everything in one tab, and tried to filter by each job, and then do the ave. starting after the 5th occurrence using =subtotal(1,RANGE). However, I cannot copy it down, I guess the filter screws up the copy down. I could create a new for each job, do the ave, and then combine it all back into 1 Spreadsheet.. I was just looking for an easier way where the data is already together..

  9. #9
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    If you are going to use a real date in your query, then the format is a bit different.

    > DateDiff("d",-6,#11/7/2010#)

    But why would you use a real date like that? I think there is something I am missing.

  10. #10
    ctrapper is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Dec 2011
    Posts
    7
    Aytee.. let me try to clean up my explanation, and by the way, the date formula now works but I am not sure if it solved the issue.. so let's go this route.. I added a column in EXCEL and assigned a # sequence to the number of times the job ran. Example Job "ATL" ran 80 times over a given period, so I # each row where the job ran in sequential order 1-80. All I am wanting to do is easily obtain a rolling average, right now I am thinking after 5 occurrences. I should take the date of the equation because they don't run every day. So with that being said, I have a column where I want the Average to go, so in the Row that contains the 6th occurrence I want would like to populate the average of 1-5, then on the 7th occurrence I want the average for 2-6 and so on.. does this help? Here's my issue.. there are 30 jobs all listed in EXCEL, I can filter by Job but I cannot find a way to Average because the filter messes up the =subtotal(1, Range) I am using to Ave when using a filter. Someone suggested using SQL, but I don't have an SQL application, so they recommended ACCESS. If I am better of in EXCEL let me know. Thanks for all the help!

  11. #11
    ctrapper is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Dec 2011
    Posts
    7
    Good grief.. you can close this.. I apologize.. I didn't even think to do a sort in excel so all the jobs were grouped together where I could use the average formula then resort by sequence.. thanks for all the help!

  12. #12
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Excel is usually better at calculations and Access is better at storing and manipulating data.

    Good luck!

  13. #13
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    You might get some ideas from this if you still want to try Access
    http://support.microsoft.com/kb/210138

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

Similar Threads

  1. Computing Question
    By elvin0809 in forum Forms
    Replies: 3
    Last Post: 10-16-2011, 12:27 PM
  2. help me get the average please! :(
    By joebox8 in forum Access
    Replies: 3
    Last Post: 07-13-2011, 08:31 AM
  3. Average help please
    By C90RanMan in forum Programming
    Replies: 1
    Last Post: 08-01-2010, 12:14 PM
  4. Replies: 13
    Last Post: 05-28-2010, 11:57 AM
  5. computing total sales per day using query
    By joms222 in forum Queries
    Replies: 0
    Last Post: 03-09-2009, 10:58 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