Results 1 to 3 of 3
  1. #1
    pjdube is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    May 2017
    Posts
    25

    Chart based on query but to show distinct totals

    Hey guys,



    OK, so I am new to this and would like some pointers if you don't mind.

    I have a MS Access form which is UNBOUND, on this form it has a Date Range. When I execute it I have a chart (line chart) that populates by a certain area and the date range, however, I cannot for the life of me figure out how to select distinct values (I don't want Joe Blow to be counted twice) when I sum up the date range - I just want it to count the distinct names.

    Here is the SQL of the chart I have:

    Code:
    SELECT [Query by Date].[Service Area], Count([Query by Date].Public) AS CountOfPublic
    FROM [Query by Date]
    GROUP BY [Query by Date].[Service Area];
    When I type in SELECT DISTINCT at the beginning -- it does nothing. I am assuming that the DISTINCT should be right after Count, but then when I do that it comes up with an error.

    Help please!

    THanks.

    Phil

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    First you need a query that returns DISTINCT Public for each Area for the given range.

    SELECT DISTINCT Public, Area FROM tablename WHERE [datefield] BETWEEN [startdate] AND [enddate];

    Then use that query as source for Count.

    SELECT Area, Count(*) AS CountPublic FROM query1 GROUP BY Area;

    Provide sample data if you need more help.
    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
    pjdube is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    May 2017
    Posts
    25
    June7

    Thanks a million. You hit the nail on the head. I did as you described and it worked.

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

Similar Threads

  1. Replies: 6
    Last Post: 08-27-2015, 11:35 PM
  2. Query will not show distinct lines
    By zbaker in forum Queries
    Replies: 2
    Last Post: 01-20-2015, 02:24 PM
  3. Replies: 2
    Last Post: 01-08-2015, 12:41 AM
  4. Replies: 7
    Last Post: 07-11-2013, 10:45 AM
  5. Replies: 1
    Last Post: 03-15-2007, 03:38 PM

Tags for this Thread

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