7 Replies Latest reply on May 1, 2013 6:18 AM by Jonathan Drummey

    How to build this stacked bar chart?

    Glen Park

      Hello everyone!


      I'm very new to Tableau (but not to data warehousing) and just starting to learn this wonderful tool, so please bear with me.  I'm tasked with creating a report with a stacked bar chart which will display aggregated numbers of purchase orders and how many days they were late shipping out.  The data essentially looks something like this:


      po_id, po_created_dt, expected_shp_dt, actual_shp_dt







      What my end users are looking for visually is a stacked bar chart that will group these purchase orders by their created dates on the x-axis but they will be color coded into groups vertically (each color representing a "days late" range...i.e. 1 day late, 2 days late, 3 days late, 4+ days late).


      On top of that I'd like to label each vertical group as a percentage of the total number of purchase orders that are late, for instance all purchase orders that are 1 day late are 10% of the total number of late purchase orders. 


      I've been playing around with this and only have gotten as far as creating a couple of calculated measures that determine the number of days late and what's basically a flag column to list as what vertical group they belong to.  But after that I'm rather lost.  Any help is greatly appreciated.




        • 1. Re: How to build this stacked bar chart?
          Jonathan Drummey

          Hi Glen,


          How about something like the attached?



          • 2. Re: How to build this stacked bar chart?
            Glen Park

            Yes that's very similar to what I'm looking for.  Thank you!

            • 3. Re: How to build this stacked bar chart?
              Jeff Voigt

              I have been working with Tableau for a little while and have had luck making some fairly good visualizations of data.  I ran into a similar problem.  It is beyond frustrating to make a stacked bar chart in tableau off of a fairly simple data set.  I could do it in excel in 5 minutes but Tableau does not seem to want to allow me to stack media spend by month. 

              • 4. Re: How to build this stacked bar chart?
                Jonathan Drummey

                Hi Jeff,


                Tableau's approach to stacked bars is definitely different from Excel, and has some dependencies on the shape of your data. A stacked bar chart can be done as quickly as two click+drag operations, or require some reshaping of the data. If you post some sample data and a packaged workbook, I'm sure someone can help.



                • 5. Re: How to build this stacked bar chart?
                  Aran Bates

                  Hi Jonathan,


                  I am having difficulty creating a stacked bar chart. I know it would be helpful to post the data but unfortunately I allowed to so I will describe it best I can.


                  I have a column field that contains a branch ID (of which there are only 4) and then column fields which contain the revenue from each product (a new field, thus column, for each product). So for each record I have a branch ID and then the total revenue from each product being sold.


                  What I want is a stacked bar chart which is separated by branch (giving 4 overall columns) with the total revenue from each product stacked within that column. So I can see the total revenue from each branch and then how that is broken by product.


                  Now what keeps happening is that Tableau will break out the data into a new chart for each product and will stack the branches. Now for the life of me I can't seem to switch it around or generate the stacked bar chart as described above.


                  This seems like a very simple ask of Tableau so I am surprised at how difficult it is when it would be a simple case ask of excel. 


                  Any help would be gratefully appreciated.




                  • 6. Re: How to build this stacked bar chart?
                    Aran Bates

                    OK so I have worked it out now that you need to create a side-by-side bar chart and then drag "measures names" to the "color" mark. However, this seems like a bit of a convoluted way to get there. Is there a better way?


                    Also, is there a way to have stacked bar charts appearing next to each other but by column? The data is stored in a flat excel file with a field for each current product sale and predicted product sales. So it would be stacking the sum, by branch, of each product sales and then placing this stacked bar next to the stacked bar of sum, of the same branch, of each predicted product sales.


                    So something that might look like this. Capture.JPG

                    Where the bars go current sales for branch 1, predicted sales for branch 1, current sales for branch 2, predicted sales for branch 2, and so on.

                    Then they are broken down by individual product type. It is a little bit of a fiddle in excel so hoping tableau will make it easier.


                    Many thanks,



                    • 7. Re: How to build this stacked bar chart?
                      Jonathan Drummey

                      Hi Aran,


                      Without some sample data it is impossible to give you exact advice. In general, Tableau prefers "tall" data (lots of rows) to "wide" data (lots of columns). Another general rule of thumb is that if a view is hard to build in Tableau, then you probably need to look at how your data is shaped.


                      To me, a couple of data layouts that would easily get to what you want would be one row per branch/product, with columns for predicted & current. Then the chart would be built with Branch on Columns, Measure Names on Columns, Measure Values on Rows, and the Product on Color. Alternatively, one row per branch/product/(predicted sales or current sales) with a dimension that that indicated whether the row was for predicted sales or current sales, then you'd have the Branch and the Sales Type dimension on Columns, the Sales on Rows, and the Product on Color.