+ Reply to Thread
Results 1 to 23 of 23

2-D Stacked bar chart

  1. #1
    Registered User
    Join Date
    01-10-2024
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    12

    2-D Stacked bar chart

    Hi everyone,

    I have four separate tables for four people. Each table summarizes what tasks that person is doing at different times of the day. Each person can only do one task at a time, but each task can be done by more than one person at a time. Also, a person might do the same task at different times on the same day. I have prepared the tables and drawn the charts I want on a piece of paper, but I am not able to generate the same charts in Excel. I was hoping someone here might be able to help me with this.

    Thank you so much

  2. #2
    Registered User
    Join Date
    01-10-2024
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    12

    Re: 2-D Stacked bar chart

    Unfortunately I am not able to post a picture yet as I am a new user

  3. #3
    Registered User
    Join Date
    01-10-2024
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    12

    Re: 2-D Stacked bar chart

    here is a link to the image (please add "." after "ibb"): ibb co/MBHW584

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: 2-D Stacked bar chart

    I'm not sure what you have tried. It looks very similar to something like this thread: https://www.excelforum.com/excel-cha...cel-chart.html Most of the work will be taking the four tables you have and combining them into one table (or two tables -- one for each chart). Look over that discussion, then we can work on adapting your data to the strategy outlined there.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  5. #5
    Registered User
    Join Date
    01-10-2024
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    12

    Re: 2-D Stacked bar chart

    Thanks for your response. Here's what I've tried: easyupload io/up423x (please add "." before "io" to be able to download my spreadsheet). As you mentioned, I want to combine the charts so I only have two charts similar to what I've drawn on paper.

  6. #6
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: 2-D Stacked bar chart

    This group prefers that you upload your file direct to the forum. See the yellow banner(s) at the top of the page for instructions for attaching your spreadsheet file to your post.

    As I noted, the bulk of the work is combining the data from 4 separate tables into 1 table, and I see no attempt to combine the tables. What I did in your file:

    1) in A40:A43, enter each person (person1, person2, person3, person4).
    2) in B39, I enter "start". In B40:B43, enter 06:00 (since each starts at 6 AM).
    3) I note that the maximum number of tasks for each person is 5, so I enter 5 sets of "A, B, C, D, E, F, G" into C39:AL39.
    4) In C40:AL43, I enter either 0 (for tasks that a person did not perform in that "set") or a copy of the duration from rows 3 to 7 where a person did perform a task.
    5) Select A30:AL43 -> insert stacked bar chart.
    5a) My copy of Excel defaulted to "series in rows" so I execute "switch row/column" to get Excel to chart series in columns.
    6) Format the "start" series (column B) to be invisible. Format each "A" series to be the same color, each "B" series to be the same color, and so on.

    A similar sequence for the chart showing "tasks" instead of "persons."

    Does that help you see the kind of rearranging of the data that is needed for this kind of chart?

  7. #7
    Registered User
    Join Date
    01-10-2024
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    12

    Re: 2-D Stacked bar chart

    Yes I prefer too, but unfortunately I am not able to (I think there is a restriction for attaching files for new users).

    A few notes:

    1) This is only a small portion of my data, which I chose as a sample to show what I am trying to do. There might be more than five tasks for each person during the day.
    2) What you explained is very close to what I am trying to do, but it doesn't work when a person does a task more than one time during the day. For example, person 1 does tasks A, B, C, then again A, and finally D.

    Thanks

  8. #8
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: 2-D Stacked bar chart

    I think there is a restriction for attaching files for new users
    There never has been before. Make certain that you are following the instructions above exactly.

    There might be more than five tasks for each person during the day.
    In my experience with this sort of thing, one key part of setting up a good template is identifying some kind of maximum number of tasks per person per day. Your example showed 5 tasks per person per day. You as the programmer will need to determine what the actual maximum number of tasks per day will be in order to set up the template.

    it doesn't work when a person does a task more than one time during the day.
    I would have to see what you are trying to do. I see no reason why you could not set this up so that a person does the same task multiple times over the course of the day.

    If it helps, here's how I set it up (limit of 5 tasks per person per day).
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    01-10-2024
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    12

    Re: 2-D Stacked bar chart

    Under posting permissions, it says:

    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    ---------------------------------------------

    Yes, that makes sense. Thank you!

    ---------------------------------------------

    I am trying to summarize the activities being done by different workers in the production line of a manufacturing company. The purpose is to visualize the manpower needed for each task during different times of the day and optimizing the production process.

    There are a few problems with the table/chart you created I think:

    1) It doesn't seem to be very user-friendly. I prefer having separate tables for different workers and enter the start and end time for each task for each person (like what I've done in my spreadsheet); However, I want to summarize all these tables in two charts.
    2) Your chart creates different legends for the same tasks that repeat during the day and that's not the best visualization for my data

    ---------------------------------------------

    I am not sure if you were able to see my hand drawings, maybe those help you better understand what I am trying to do.

  10. #10
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: 2-D Stacked bar chart

    I was able to view your hand drawn pictures, and I thought I had come pretty close to creating the same thing in the stacked bar chart. It was quickly done and I left some of the "prettying up" undone, but the stacked bar chart I made seems pretty close to the stacked bar chart you drew.

    Your chart creates different legends for the same tasks that repeat during the day
    It should be fairly easy to delete the extra legend entries (Select the legend, then select the individual, extraneous legend entries, then delete the legend entry). Again, since most of the work in this task is arranging the data in the spreadsheet, I focused my time/effort on showing how the data should be arranged in the spreadsheet. Assuming you know how to do the necessary formatting, there should be plenty of formatting and such to clean up the chart.

    It doesn't seem to be very user-friendly. I prefer having separate tables for different workers and enter the start and end time for each task for each person (like what I've done in my spreadsheet); However, I want to summarize all these tables in two charts.
    Of course, a lot of spreadsheet programming is trying to make spreadsheet user friendly. Again, I tried to make something quick to demonstrate how the data needs to be arranged. There is a lot of work to go through to make this more user-friendly.

    I can appreciate your preference for individual tables for each person. One of the premier charting gurus, Jon Peltier, has this to say: "What if you want to plot your data but also display it in an optimally formatted way? The good new is, you can. The bad news is, it takes more work. You should have two different data ranges: one arranged for best charting outcomes, the other formatted for visual consumption. Both of these ranges should link to the same original source, to make sure changes are reflected everywhere, and you maintain one version of the data." (see here: https://peltiertech.com/good-chart-data/ ). I think a big part of programming this template is to determine exactly how you want to interact with the sheet, recognize that it's okay (and maybe necessary in this case) to have two or more copies of the data (properly linked so that you need only edit the data in one place). In this case, we probably need to figure out lookup or similar formulas for B41:AL44 that will retrieve the necessary information from the four tables above (or some other strategy for bringing the necessary data into the chart table from wherever the data have originally been entered). I might even go so far as to say that this might be easiest to do as a database project where we enter the raw data into a good database, then build both your individual person tables from that database and build the chart table from that database.

    Anyway, all that to say that, yes, there is still more programming to do in order to streamline this. As you determine what kind of strategies and such you want to use to accomplish these tasks, let us know how we can help with that programming.

  11. #11
    Registered User
    Join Date
    01-10-2024
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    12

    Re: 2-D Stacked bar chart

    Quote Originally Posted by MrShorty View Post
    I was able to view your hand drawn pictures, and I thought I had come pretty close to creating the same thing in the stacked bar chart. It was quickly done and I left some of the "prettying up" undone, but the stacked bar chart I made seems pretty close to the stacked bar chart you drew.

    It should be fairly easy to delete the extra legend entries (Select the legend, then select the individual, extraneous legend entries, then delete the legend entry). Again, since most of the work in this task is arranging the data in the spreadsheet, I focused my time/effort on showing how the data should be arranged in the spreadsheet. Assuming you know how to do the necessary formatting, there should be plenty of formatting and such to clean up the chart.
    Yeah for sure, that's very close and I really appreciate you spending time and effort to help me. It's just the very tiny details that are bothering me lol. I want the chart to automatically understand that if a task is repeated a couple times during a day, it should show them all with the same color on the chart and use the same legend for them.

    Quote Originally Posted by MrShorty View Post
    I can appreciate your preference for individual tables for each person. One of the premier charting gurus, Jon Peltier, has this to say: "What if you want to plot your data but also display it in an optimally formatted way? The good new is, you can. The bad news is, it takes more work. You should have two different data ranges: one arranged for best charting outcomes, the other formatted for visual consumption. Both of these ranges should link to the same original source, to make sure changes are reflected everywhere, and you maintain one version of the data.". I think a big part of programming this template is to determine exactly how you want to interact with the sheet, recognize that it's okay (and maybe necessary in this case) to have two or more copies of the data (properly linked so that you need only edit the data in one place). In this case, we probably need to figure out lookup or similar formulas for B41:AL44 that will retrieve the necessary information from the four tables above (or some other strategy for bringing the necessary data into the chart table from wherever the data have originally been entered). I might even go so far as to say that this might be easiest to do as a database project where we enter the raw data into a good database, then build both your individual person tables from that database and build the chart table from that database.
    That's a great quote and a very nice perspective. Thanks for sharing. I totally agree and I think I definitely should separate my raw data from the tables that I'm gonna use for creating my charts!

    Quote Originally Posted by MrShorty View Post
    Anyway, all that to say that, yes, there is still more programming to do in order to streamline this. As you determine what kind of strategies and such you want to use to accomplish these tasks, let us know how we can help with that programming.
    I really appreciate it! I mostly use Excel for basic tasks and do my programming in MATLAB. One problem for me as an amateur Excel user is that I don't exactly know the capabilities of Excel and what can/cannot be done with it. For this project (and for most of other projects I do actually), I prefer to program in a way that minimizes human interference and manual modifications. For example for the legends/chart colors, I really prefer to spend some time on my program now and make it automatic rather than to do the modifications afterwards every time I generate new charts. However, as I said before, I am not sure if this is doable in Excel :D

    Thanks again

  12. #12
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: 2-D Stacked bar chart

    Excel can do this. One possible way to automate the copying of the data in the top tables into the chart table might look like (starting from my file in post #8):

    1) In row 39, replace the 1st task, etc. with 1 in C39:I39, 2 in J39:P39, and so on.
    2) Replace Aduration, etc. in row 40 with simple A, B, C,...
    3) Build a formula in C41 that will a) test if the task in A3 matches the task in C40 then, b) if it matches, return the value from D3, else c) return 0. In a spreadsheet, this kind of decision is performed by an IF() function (https://support.microsoft.com/en-us/...c-aa8bbff73be2 ).
    3a) Use an INDEX() function (https://support.microsoft.com/en-us/...2-b56b061328bd ) to access the value in the first cell of A3:A7. INDEX($A$3:$A$7,C$39) [note the mix of relative and absolute references for easy copying]. Compare to the value in C40 -- INDEX(...)=C$40. Use that as the test condition in the IF() function =IF(INDEX(...)=C$40,...)
    3b) If true, then we want to use and INDEX() function to return the value from D3, if not, return 0 =IF(INDEX(...)=C$40,INDEX($D$3:$D$7,C$39),0)
    4) Enter that function in C41. Then copy C41 and paste/fill into C41:AL41.
    5) Repeat step 4 in C42, C43, C44, replacing the references for person 1 with appropriate references for person 2, person 3, person 4.

    Now, you can enter your values in the tables at the top of the sheet, and those entries/edits should be reflected in the chart table and in the chart.

  13. #13
    Registered User
    Join Date
    01-10-2024
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    12

    Re: 2-D Stacked bar chart

    Thanks MrShorty. Now that we have a new single table, how do you think we can fix the legend/chart color problem?

  14. #14
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: 2-D Stacked bar chart

    As I noted in step 6 of post #6, go through and format each "A" series to be the same color, each "B" series to be the same color, and so on. It will be easy, if a bit tedious the first time through. Then go through the legend and delete the "extra" legend entries. As I noted earlier, select the legend, then select the desired legend entry, then delete/clear. Again, it should be easy, even if it is a bit tedious the first time you set up the template.

    Let me know if you have any difficulty with either of those tasks.

  15. #15
    Registered User
    Join Date
    01-10-2024
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    12

    Re: 2-D Stacked bar chart

    That makes sense, thank you. I have another question now. What if there is a delay between two tasks (for example, what if person 1 starts his first task at 6:00 and finishes at 7:00, but he doesn't start his second task until 7:05)? I guess in the current format, the tasks need to be done back to back, right?

  16. #16
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: 2-D Stacked bar chart

    Delays, pauses, breaks will fit seamlessly into the current template if you treat these as their own task. Our identifiers are currently generic, so we could say that Task G represents the "delay, pause, break" task. If you are willing to treat these delays as if they are just another task, then it should fit seamlessly into the existing template. The challenge will be if you insist on not treating delays the same as other tasks.

  17. #17
    Registered User
    Join Date
    01-10-2024
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    12
    Quote Originally Posted by MrShorty View Post
    Delays, pauses, breaks will fit seamlessly into the current template if you treat these as their own task. Our identifiers are currently generic, so we could say that Task G represents the "delay, pause, break" task. If you are willing to treat these delays as if they are just another task, then it should fit seamlessly into the existing template. The challenge will be if you insist on not treating delays the same as other tasks.
    Yeah that's exactly what I was thinking, I'll work on that and see how it goes! Thank you so much 😊

  18. #18
    Registered User
    Join Date
    01-10-2024
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    12

    Re: 2-D Stacked bar chart

    Hi again,

    I think my tables are good now, but the timing seems to be off in my second chart (the first chart looks fine to me, but if you compare the second chart with my hand drawings you'll get what I mean). Would you be able to help me fix that please?

    easyupload io/f1jxz5 (Sorry, I still have trouble uploading files here! Please see Sheet 3.)

    Thanks

  19. #19
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: 2-D Stacked bar chart

    Timing in the chart matches what is in the table. If I understand what you are trying to do, it appears that there is nothing in the formulas in the table in rows 49 to 55 that will detect "task X was not worked on by anyone for Y duration." If we can figure out how to include that kind of logic in these formulas, then the chart should follow the data in the table. I don't have time at the moment to think through the logic.

    This is where it might be easier to have more of a database input format, then extract all of the different tables from that source data, rather than enter the data into the "single person" tables like we are currently doing. How willing are you to completely redesign the spreadsheet?

  20. #20
    Registered User
    Join Date
    01-10-2024
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    12

    Re: 2-D Stacked bar chart

    I don't mind redesigning the spreadsheet, as long as it works. Any suggestions or samples that explain how I should approach the problem?

  21. #21
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: 2-D Stacked bar chart

    These aren't the kind of spreadsheets I design, so I am struggling (in the limited time I can devote to this) to come up with a good spreadsheet design. Hopefully someone else can chime in. My thought at present is that a good list "database" where you enter the data might be best. Your tables (both for reporting and for the chart) could possibly be extracted from the list/database using filters or pivots. I have sent out feelers into the community to see if anyone has ideas for designing the spreadsheet.

  22. #22
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: 2-D Stacked bar chart

    Quote Originally Posted by ahs74 View Post
    Under posting permissions, it says:
    ...
    You may not post attachments
    This is wrong, sorry. Anyone can attach files to a post. I'll see if I can get that fixed, but I don't have privileges to do it myself.

    You may have bumped into a size limit. The limit for .xlsx files is 1MB. If it's larger you can zip it or convert to .xlsb. For some reason, the limit for those file types is 9.77MB.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  23. #23
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,570

    Re: 2-D Stacked bar chart

    I have been working on this off and on since Mr. Shorty made the calvary call.
    In its present form this is likely to be impractical, but perhaps it will inspire a thought in someone that will prove workable.
    It seems to me that the Crew chart is working as desired, so what I am addressing is the Task chart.
    I propose using a Gantt chart produced as follows.
    1. Use Get & Transform to combine the person tables on Sheet 3 using the following code:
    Please Login or Register  to view this content.
    2. From the query produced table (green/white) on the Query1 sheet use the following formula to fill cells H5:S11
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    3. Use the following code to produce the Gantt chart in cells H16:S25
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    4. Several conditional formatting rules are applied to the cells containing names as well as one for the blank cells.
    Let us know if you have any questions.
    Attached Files Attached Files
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Combine stacked columns and stacked bars in a chart
    By maboho93 in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 02-09-2018, 07:52 AM
  2. Replies: 5
    Last Post: 12-09-2015, 12:41 PM
  3. Stacked bar chart with stacked secondary axis markers - please help!
    By Boardlady in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 07-22-2013, 10:32 AM
  4. Replies: 1
    Last Post: 05-30-2013, 10:03 AM
  5. How can I combine a stacked bar chart with stacked colum chart?
    By Sin in forum Excel Charting & Pivots
    Replies: 8
    Last Post: 12-19-2005, 11:55 PM
  6. Replies: 1
    Last Post: 03-26-2005, 02:06 PM
  7. [SOLVED] To create a stacked column chart and group the stacked bars togeth
    By Jacqueline in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 02-18-2005, 10:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1