Results 1 to 14 of 14
  1. #1
    King_Black is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2017
    Posts
    8

    Stacked area chart with multiple values in the x axis

    Hi All,



    First message for me in this nice forum. I hope I can contribute in the future!

    I spent hours trying to solve this problem without luck... Attached there is a super simplified version of the database that I'm currently using.

    The database has been previously structured in a weird way. Basically the columns plans_week1, plans_week2, etc show the amount of hours spent by an employee in a week.

    Is there a way to create a report with an area chart that shows the weeks (plans_week1, plans_week2,etc) in the x axis (like the one that I have made in excel)?

    Thanks a lot!
    Attached Files Attached Files

  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
    52,920
    Remove the grouping from Query1, make just a normal SELECT joining tables.

    Build a UNION query:

    SELECT proj_type, 1 AS weekNum, plans_week1 AS Data FROM Query1
    UNION ALL SELECT proj_type, 2, plans_week2 FROM Query1
    UNION ALL SELECT proj_type, 3, plans_week3 FROM Query1
    UNION ALL SELECT proj_type, 4, plans_week4 FROM Query1
    UNION ALL SELECT proj_type, 5, plans_week5 FROM Query1
    UNION ALL SELECT proj_type, 6, plans_week6 FROM Query1;

    RowSource for chart:
    TRANSFORM Sum([Data]) AS [SumOfData] SELECT [weekNum] FROM [Query2] GROUP BY [weekNum] PIVOT [proj_type];
    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
    King_Black is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2017
    Posts
    8
    Hi June7, thank you very much for your answer. You're very kind!
    How do you structure the union query if there would be an additional column in the Query1? "Disc_description" is supposed to be the "link" between the chart and the report itself.
    Apologies if I didn't include it before.
    Attached Files Attached Files

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,920
    Just put the field name in each line.

    How is it a link to the report? The chart uses a CROSSTAB query as RowSource. Review http://allenbrowne.com/ser-67.html#Param
    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
    King_Black is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2017
    Posts
    8
    In the chart wizard, after I selected the area chart, If I want the chart to change from record to record, I should select the fields that link the document and the chart. The fields are supposed to be "Disc_description". Sorry but I'm not very familiar with access

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,920
    My charts have all been XYplots using a simple SELECT as RowSource, example: SELECT Size, Pass, Hi, Lo FROM GraphBMD WHERE LabNum=[tbxLabNum] ORDER BY Size;

    [tbxLabNum] is reference to a control on report. This synchronizes the chart data with the report data. Never could figure out how to get the Master/Child Links properties of chart to work.

    If you saved the CROSSTAB as an object, then the chart RowSource can be: SELECT weekNum, [Annual Leave (TOWP)], Backlog, [Internal Order activity], [Leave Without Pay], Overhead, [Proposal activity], Prospect FROM Query3;

    I have never had to use CROSSTAB queries for any reason in my db's, not even charts. Lucky me. So I have never had to apply filter to CROSSTAB. Applying dynamic filter when CROSSTAB is involved requires use of PARAMETERS in query as explained by Allen Browne link.
    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
    King_Black is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2017
    Posts
    8
    Solved! Thank you very much for your help mate!

  8. #8
    King_Black is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2017
    Posts
    8
    Last question actually: How can I change the order of the areas? Right now the areas are automatically ordered in alphabetical order but that doesn't suit my needs.
    I can easily do that in the union query adding an additional parameter (like 1 to Backlog, 2 to Prospect, etc) but I can't figure out how to do so in the Row Source.
    The parameter that I would like to use to order the chart areas it shouldn't be included in the chart though. Not sure if it is clear :-/

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,920
    Instead of using CROSSTAB as the chart RowSource, use the SELECT that pulls from the CROSSTAB. Order of areas will be determined by order the fields are referenced.
    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.

  10. #10
    King_Black is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2017
    Posts
    8
    Ok, but the CROSSTAB: TRANSFORM Sum([Data]) AS [SumOfData] SELECT [weekNum] FROM [Query2] GROUP BY [weekNum] PIVOT [proj_type];

    gives me the Row heading (weekNum) and the columns (backlogs,prospects, etc). What should I use in the RowSource as value? And what should I use as PIVOT?

  11. #11
    King_Black is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2017
    Posts
    8
    Also How do I hard code some columns in the query? I need that as the charts colours are not consistent. This is because the some fields are populated with values in some Disc_description but others are not.
    Jeez I'm going back to excel lol

  12. #12
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,920
    See post 6. Save the CROSSTAB as a query object. Then the chart RowSource is just a SELECT query.

    What do you mean by hard code columns? You want to set colors? Have a look at https://www.accessforums.net/showthread.php?t=29178
    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
    King_Black is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2017
    Posts
    8
    Problem solved. Thank you very much June7. I really appreciated it! My hope is that in the future I can become competent as you.

  14. #14
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,920
    Might find this interesting http://allenbrowne.com/ser-67.html#ColHead
    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.

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

Similar Threads

  1. Stacked column and line chart
    By Soumya in forum Programming
    Replies: 1
    Last Post: 10-14-2015, 09:28 AM
  2. Chart Y Axis Whole Integers
    By james28 in forum Reports
    Replies: 3
    Last Post: 08-21-2014, 12:31 PM
  3. Scaling a Chart Axis
    By Paul H in forum Reports
    Replies: 5
    Last Post: 10-16-2013, 01:50 PM
  4. Replies: 1
    Last Post: 05-04-2012, 02:22 PM
  5. Scatter Chart not Showing X-axis Values
    By ward0749 in forum Forms
    Replies: 4
    Last Post: 03-20-2012, 06:37 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