6 Replies Latest reply on Mar 23, 2017 4:20 AM by Okechukwu Ossai

    Creating a gantt chart with stacked bars

    Kiki Mul

      Dear Tableau Community,

       

      I am new to tableau and have the following data set:

       

      And am trying to create the following output:

      I found some posts asking similar questions, but in all cases the solution was to change the source data. This is not an option for me, as the source data is generated by another tool. Is there another way, than changing the source data?

       

      Thanks,

      Kiki

        • 1. Re: Creating a gantt chart with stacked bars
          Okechukwu Ossai

          There are so many things you can do. You won't change the source data. It will only require slight data preparation by adjusting the data structure to enable Tableau produce the charts.

           

          For example you can't produce a Gantt chart in Tableau if you don't have Start Date and End Date as separate fields or a single field. This will help you to caculate Duration in days. You will still need another field combining Manufacturing, Testing and Shipping as subcategories before you can use it to color the chart.

           

          All these can be done quite easily. To start I will like to know few things about your data set. How does your data get into Tableau? Is it through an Excel data source or a SQL database?

           

          Ossai

          • 2. Re: Creating a gantt chart with stacked bars
            Kiki Mul

            HI Ossai,

             

            It is through Google sheets, but for simplicity we can assume it is Excel.

             

            Please see attached Excel sheet.

             

            Thanks!

            K.

            • 3. Re: Creating a gantt chart with stacked bars
              Okechukwu Ossai

              I'll take a look and get back to you.

               

              Ossai

              • 4. Re: Creating a gantt chart with stacked bars
                Okechukwu Ossai

                Hi Kiki,

                 

                I have a solution for you by using Custom SQL to automatically reshape the data whilst it is being loaded into Tableau.

                This is important because data must be in the right format, otherwise certain analysis will be impossible in Tableau.

                 

                For this chart to work your data should be in the format below.

                The good news is that you don't need to modify your excel file. I wrote a custom SQL code which will do this automatically for you.

                The custom SQL script is attached. You have to make sure that the column names and table structure are exactly as the example data you attached.

                If you change them then you must update the custom SQL also.

                 

                Steps:

                 

                1. Open a new Tableau workbook and click on the Excel file connection.

                Select the file and click on the drop down arrow beside "Open" and choose "Open with legacy connection".

                 

                 

                2. A new window will open. Double click on "New Custom SQL".

                Copy and paste the attached custom SQL into the Edit Custom SQL box and click OK.

                 

                 

                3. That's it! Your original data is now reshaped into a format that Tableau can work with it.

                 

                 

                4. Check the attached workbook to see what I have done.

                Note that I created a calculated field [Duration] in days to help connect the Start Gantt bars to the End bars.

                Let me know if you have any questions.

                 

                Hope this helps.

                 

                Ossai

                1 of 1 people found this helpful
                • 5. Re: Creating a gantt chart with stacked bars
                  Kiki Mul

                  Hi Ossai,

                   

                  Thank you very much not only for the solution, but also for taking the time to describe all the steps! It is very much appreciated.

                   

                  Before I posted my question, I had actually tried to solve "my problem" by using pivoting in Tableau, but I got stuck.

                   

                  Thanks again!

                  Regards,

                  K

                  • 6. Re: Creating a gantt chart with stacked bars
                    Okechukwu Ossai

                    You're welcome Kiki. I'm glad it helped.

                     

                    Could you please mark the answer as correct?

                     

                    Regards,

                    Ossai