Results 1 to 11 of 11
  1. #1
    Currancchs is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    11

    Making a graph/chart using DCount

    Hi guys,



    I have a query where I use the DCount function to give me four separate fields. I want each of the field titles to become a portion of a pie chart. My problem is that I need to have two fields only for the pie chart, one with the DCount field names, and the other with the values. I cannot figure out how to rearrange the data. This can't be as hard as I'm making it, any advice (including you're doing it wrong, do it this way) would be appreciated.

    Thanks!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    Sounds like need UNION query to rearrange the data in normalized structure.

    SELECT "field1" As SourceField, field1 As CountData FROM queryname
    UNION SELECT "field2", field2 FROM queryname
    UNION SELECT "field3", field3 FROM queryname
    UNION SELECT "field4", field4 FROM queryname;

    There is no query wizard or designer for UNION, must type in the SQL View of query builder.
    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
    Currancchs is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    11
    Thanks for the information, once I get the data better organized, do you know how I would get it from being a pivot chart into a report. I assumed that you would be able to set default view to pivot chart and drag into a report as a subreport, but that is not working for whatever reason (I tried with another set of data I was able to graph). The option for default view as pivot chart is no longer there once dragged into the report.

  4. #4
    Currancchs is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    11
    This is what I wrote, but I'm sure I got the syntax wrong somehow...

    SELECT "Licensed Marks" As SourceField, Licensed Marks As CountData FROM [Pie Chart - Base]
    UNION SELECT "Protected and Licensed Marks", Protected and Licensed Marks FROM [Pie Chart - Base]
    UNION SELECT "Registered Marks", Registered Marks FROM [Pie Chart - Base]
    UNION SELECT "Unlicensed Registered Marks", Unlicensed Registered Marks FROM [Pie Chart - Base];

    I tried the field names with and without quotes/brackets... keep getting errors...

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    Names that include spaces must be enclosed in [].

    SELECT "Licensed Marks" As SourceField, [Licensed Marks] As CountData FROM [Pie Chart - Base]
    UNION SELECT "Protected and Licensed Marks", [Protected and Licensed Marks]FROM [Pie Chart - Base]
    UNION SELECT "Registered Marks", [Registered Marks] FROM [Pie Chart - Base]
    UNION SELECT "Unlicensed Registered Marks", [Unlicensed Registered Marks] FROM [Pie Chart - Base];
    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.

  6. #6
    Currancchs is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    11
    Thanks again for bearing with me. I played around with it some more with a simpler query and figured out the proper syntax. However, I could not base my Union Query off of another query for some reason, I had to convert the original query to a make table query, then base the union query off of the table. Is this normal functionality or should it be possible to base a union query off of a query? I kept the syntax exactly the same, just created a table with an additional character in order to test the theory that syntax was OK but the query would only work when based off of a table...

  7. #7
    Kirsti is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Jan 2012
    Location
    New Zealand
    Posts
    172
    Hi, seems strange - for what it's worth, I have never based a Union Query off a table, I always base them off Select Queries.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    I can best analyze graph issue by working with data. If you want to provide project, follow instructions at bottom of my post.
    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.

  9. #9
    Currancchs is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    11
    Unfortunately there is some proprietary information involved in this database and I cannot provide the database itself. If that means you cannot provide further assistance, I understand, and am grateful for the help you've already given. The SQL for the Union Query is pasted below though. Further, I made a table with just the name table added to the end of this, but otherwise the same syntax that gives no errors and works as anticipated. The query that the union query is based off of is a dcount query.

    SELECT "Acknowledged Actions Due" AS [Action Items], [Acknowledged Actions Due] AS [Number] FROM [Actions Due Comparison]
    UNION SELECT "Actions Due", [Action(s) Due] FROM [Actions Due Comparison];

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    Building UNION of other queries should be possible. Maybe the DCount is a complication. Don't know, never tried before. Why is DCount necessary? Maybe a GROUP BY aggregate query is possible. Again, would have to work with data to better understand issue.

    Don't need real info, dummy records would serve. Would only need objects relevant to this issue.

    If you don't want to scrub the data and provide db for analysis, don't think I can help further.
    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.

  11. #11
    Currancchs is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    11
    Thanks for the help guys, just needed to play around with it long enough. Wound up getting it to work, but locking my recordset in the process, so then I made two separate count queries and that did the trick, along with the below SQL union statement:

    SELECT "Acknowledged" AS [Action Items], IIF(ISNULL(sum([CountOfApplicationNumber])),"0",sum([CountofApplicationNumber])) AS [Number] FROM [AcknowledgedRenewalCount]
    UNION SELECT "Unacknowledged", sum([CountOfApplicationNumber]) FROM [ActionsDue];

    Marking as solved.

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

Similar Threads

  1. Replies: 6
    Last Post: 02-29-2012, 03:13 AM
  2. Graph
    By Ray67 in forum Reports
    Replies: 8
    Last Post: 10-15-2011, 10:38 AM
  3. Replies: 3
    Last Post: 01-10-2011, 10:31 AM
  4. Replies: 2
    Last Post: 07-12-2010, 05:39 AM
  5. Chart/Graph
    By Tony McGuire in forum Access
    Replies: 0
    Last Post: 09-13-2009, 04:17 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