Results 1 to 5 of 5
  1. #1
    wlkr.jk is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    20

    Combining count values for a pie chart

    Hi,



    I'd like to combine a few values to compare with another and then present in a pie chart. How am I supposed to formulate this in a query.

    I've got a main table listing out a vast amount of values with one field being StatusID.

    There are 5 possible statusID's:
    1,2,3,4,5.

    In the pie chart, I'd like to sum the count of the number of times StatusID's 1,2,3, or 4 show up in the main table (i.e. combine all the individual sums). The other count will be of StatusID 5. So, therefore I will have 2 counts to display in the pie chart.

    Thanks for your help.

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

    SELECT Count(IIf(StatusID<5,StatusID,Null) AS CountOthers, Count(IIf(StatusID=5,StatusID,Null) AS Count5 FROM tablename;
    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
    wlkr.jk is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    20
    Unfortunately that didn't completely work. It assigned a common name for all statusID which met the criteria "<5" but it didn't actually combine them in the chart. (See attached picture)

    Also, the criteria where StatusID=5 didn't work because it didn't display in the chart that count. I had 1 record which had StatusID=5 but it didn't count obviously.

    Here is what I ended up using:

    SELECT ProblemTable.StatusID, Count(IIf(StatusID<5,StatusID,Null)) AS CountOthers, Count(IIf(StatusID=5,StatusID,Null)) AS Count5
    FROM ProblemTable
    GROUP BY ProblemTable.StatusID;
    Click image for larger version. 

Name:	Pie Chart.PNG 
Views:	8 
Size:	6.8 KB 
ID:	16512

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,598
    I have your db from the other thread.

    The query in the RowSource is not what you have posted.

    This works and is in line with the query you posted:

    SELECT IIf([StatusID]<5,"Open","Closed") AS Status, Count(IIf([StatusID]<5,"Open","Closed")) AS CountStatus FROM ProblemTable GROUP BY IIf([StatusID]<5,"Open","Closed");

    Change the chart Data Labels settings to not show the series name - display the category name instead. Or show the legend.
    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.

  5. #5
    wlkr.jk is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    20
    Thanks June7. So I settled on the following:

    SELECT IIf([StatusID]<5,"Open","Closed") AS Status,
    Count(IIf([StatusID]<5,"Open","Closed")) AS CountStatus
    FROM ProblemTable
    GROUP BY IIf([StatusID]<5,"Open","Closed");

    By doing this, I was able to group everything into two categories on the pie chart (Open and closed).

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

Similar Threads

  1. Replies: 2
    Last Post: 05-27-2013, 09:25 AM
  2. Replies: 7
    Last Post: 12-05-2012, 10:10 AM
  3. Chart - Count of value
    By libraccess in forum Reports
    Replies: 2
    Last Post: 10-24-2012, 10:54 PM
  4. Combining two boolean values
    By John_B in forum Access
    Replies: 6
    Last Post: 02-11-2012, 11:45 AM
  5. Replies: 0
    Last Post: 03-26-2011, 09:59 AM

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