Results 1 to 3 of 3
  1. #1
    michaelwh1 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    9

    Counting number of occurances by date


    I have a table that tracks differents events and the acctual date they occured. I am trying to write a query that counts the number of each event that occured by month. One issue I am having is if an event had no occurence during a month I want to return 0 raher than no data for that event. Help is appreciated.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,598

    Show count for every month

    Options:

    1. Need a dataset of all possible month and event combinations. This dataset could be created by a cartesian join of a months table and events table (or queries that generate those sets). Review attached file. In this example, I have one table that has at least one record for every possible event (only two events) and a record for every possble month. Each month has one or the other or both events. If that would not be the case for you then have a table of all events that could be scheduled. Also, if cannot rely on the table having at least one record for each month, then need a table of months.

    2. Use DCount to query the table. Would need a calc for each month/event pair. How many events do you have? Example:
    DCount("*","tablename","Month([EventDate])=x AND EventID=x")
    Attached Files Attached Files
    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
    michaelwh1 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    9
    Thanks. This solution works. Very much appreciated.

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

Similar Threads

  1. Counting Instances of a Number
    By SealM in forum Queries
    Replies: 9
    Last Post: 02-04-2013, 09:35 AM
  2. Counting number of instances by time of day
    By Abarency in forum Queries
    Replies: 1
    Last Post: 11-11-2012, 04:53 PM
  3. Replies: 21
    Last Post: 11-07-2012, 02:14 PM
  4. Only include unique occurances
    By filla_dilla in forum Queries
    Replies: 8
    Last Post: 07-18-2011, 10:22 PM
  5. Counting the number of enrollees on a course
    By slaterino in forum Access
    Replies: 2
    Last Post: 10-12-2010, 12:24 AM

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