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

    Chart - Need to refer name to ID in horizontal axis

    Hi,

    I have a chart which is counting the number of times each specific ID (ProcessID) number occurs in a master table (ProblemTable). See attached for view of chart.

    The chart is a bar chart with a simple count and the horizontal axis has each of the unique ProcessID's. However, instead of the ProcessID, I'd like the associated ProcessName which is given in ProcessTable to be on the horizontal axis.

    Here is the SQL code that I used for the simple ProcessID count on the chart:
    Code:
    SELECT ProblemTable.[ProcessID], Count(ProblemTable.[ProcessID]) AS CountOfProcessID
    FROM ProblemTable
    GROUP BY ProblemTable.[ProcessID];
    Here is the SQL code that I came up with to change the axis to ProcessName (but doesn't currently work):


    Code:
    SELECT ProblemTable.[ProcessID], ProcessTable.[ProcessName], Count(ProblemTable.[ProcessName]) AS CountOfProcessID
    FROM ProblemTable INNER JOIN ProcessTable
    ON ProblemTable.[ProcessID] = ProcessTable.[ProcessID]
    GROUP BY ProblemTable.[ProcessName];
    Thanks for your help.

    Jake
    Attached Thumbnails Attached Thumbnails Chart.PNG  

  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,770
    Try:

    SELECT ProcessTable.[ProcessName], Count(ProblemTable.[ProcessID]) AS CountOfProcessID
    FROM ProblemTable INNER JOIN ProcessTable
    ON ProblemTable.[ProcessID] = ProcessTable.[ProcessID]
    GROUP BY ProblemTable.[ProcessName];
    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
    Quote Originally Posted by June7 View Post
    Try:

    SELECT ProcessTable.[ProcessName], Count(ProblemTable.[ProcessID]) AS CountOfProcessID
    FROM ProblemTable INNER JOIN ProcessTable
    ON ProblemTable.[ProcessID] = ProcessTable.[ProcessID]
    GROUP BY ProblemTable.[ProcessName];
    Thanks I tried that but it came up with the following error: Click image for larger version. 

Name:	error.PNG 
Views:	14 
Size:	18.8 KB 
ID:	16503

  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,770
    Change the table prefix of the field in the GROUP BY clause. Sorry I did not notice the difference.
    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
    I actually changed the GROUP BY clause before since I noticed my mistake.

    Chart remains unchanged. Horizontal axis values are still listed as the ProcessID's.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    That doesn't make sense to me. That SQL is the chart RowSource?
    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.

  7. #7
    wlkr.jk is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    20
    Yes the SQL code is in the Row Source

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Since ProcessID is not in the SELECT clause, I don't understand how the graph can reference it.

    If you want to provide db for analysis, 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
    wlkr.jk is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    20
    Forum DB for debug.zip

    Thank you for your help.

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    The bar chart RowSource is not the second query you posted nor the version I suggested.

    SELECT ProcessTable.[ProcessName], Count(ProblemTable.[ProcessID]) AS CountOfProcessID
    FROM ProblemTable INNER JOIN ProcessTable
    ON ProblemTable.[ProcessID] = ProcessTable.[ProcessID]
    GROUP BY [ProcessName];
    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
    wlkr.jk is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    20
    That's awesome thank you for figuring that out!

    I just have one more question about that code, now. I'd like to not include processes in the chart if their status is '5' (so that when their count is 0, it's not a blank part in the chart).

    Here is what I figured out on my own based on what you just provided:

    SELECT CASE
    WHEN ProblemTable.[StatusID]<5 THEN ProcessTable.[ProcessName]
    ELSE Null
    END, Count(IIf(ProblemTable.[StatusID]<5,ProblemTable.[ProcessID],Null)) AS CountOfProcessID
    FROM ProblemTable INNER JOIN ProcessTable
    ON ProblemTable.[ProcessID] = ProcessTable.[ProcessID]
    GROUP BY [ProcessName];

    But I'm getting the following error:
    Click image for larger version. 

Name:	SQLError.PNG 
Views:	15 
Size:	10.9 KB 
ID:	16527

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I've never seen that syntax in an Access query. I don't know about using CASE in query.

    If you want to exclude the status 5 records, then use WHERE clause.

    WHERE StatusID < 5
    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.

  13. #13
    hapm is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    197
    CASE is T-SQL. Use the IIf function instead.

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

    SELECT LineTable.SubLine,
    Count(IIf(Now()<ProblemTable.[DatetobeClosed],IIf(ProblemTable.StatusID<5,ProblemTable.[LineID],Null),Null)) AS [On Time],
    Count(IIf(Now()>=ProblemTable.[DatetobeClosed],IIf(ProblemTable.StatusID<5,ProblemTable.[LineID],Null),Null)) AS [Overdue]
    FROM ProblemTable INNER JOIN LineTable ON ProblemTable.[LineID] = LineTable.[LineID]
    GROUP BY LineTable.SubLine
    ORDER BY Count(IIf(ProblemTable.StatusID<5,ProblemTable.[LineID],Null)) DESC;

    For everyone's information, the problem table stores problems to be followed up on with a "date entered" and a "date to close the problem".

    With this, the chart lists problems by line in descending order and has the name of the line on the horizontal axis as opposed to the LineID from the LineTable.

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

Similar Threads

  1. Scaling a Chart Axis
    By Paul H in forum Reports
    Replies: 5
    Last Post: 10-16-2013, 01:50 PM
  2. Y Axis Scale Problem on XY Scatter Chart
    By Paul H in forum Access
    Replies: 1
    Last Post: 01-15-2013, 06:14 PM
  3. Replies: 5
    Last Post: 01-15-2013, 01:15 PM
  4. Chart axis change with .Chartype changes
    By alangea in forum Programming
    Replies: 2
    Last Post: 05-20-2012, 12:41 PM
  5. Scatter Chart not Showing X-axis Values
    By ward0749 in forum Forms
    Replies: 4
    Last Post: 03-20-2012, 06:37 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