4 Replies Latest reply on Sep 13, 2013 11:27 AM by Adam Robins

    Show Percentages instead of Mark Labels

    Adam Robins

      Hello, I am in need of assistance regarding the attached example workbook.  This is not the real-life scenario, but a vastly simplified example to demonstrate my situation.

       

      I have one record per order.  Each order undergoes three processes for a varying number of minutes.  In the database, Each order record has a separate field to record the minutes of each process.

       

      My example shows a stacked bar for each order.  The reference line shows the sum of the process times for each order.  If I turn on Mark Labels, it will show the actual minute values of each process.  However, what I would really like to show is the percentage that each process contributes to the total of each order.  How can I do this?

       

      In a related issue,  I would also like to be able to filter on Process1Min, Process2Min, Process3Min, which I cannot do because each is now a separate measure.  Any ideas how to do this?  I am not beyond having to remodel the source data.

       

      Thanks.

        • 1. Re: Show Percentages instead of Mark Labels
          Pedro Machado

          Hi Adam,

           

          I believe the best thing to do long term is to reshape your data so that it's easier to look at it in Tableau.

           

          If your only have three processes, you could create a view/table in your database or use custom SQL in Tableau to reshape your data. This is what it would look like:

           

          SELECT order_id,

                        'Process1" as process_type,

                        Process1Min as process_duration,

                       color,

                       size,

                       model

          FROM   yourtable

          UNION ALL

          SELECT order_id,

                        'Process2" as process_type,

                        Process2Min as process_duration,

                       color,

                       size,

                       model

          FROM   yourtable

          UNION ALL

          SELECT order_id,

                        'Process3" as process_type,

                        Process3Min as process_duration,

                       color,

                       size,

                       model

          FROM   yourtable ;

           

          This would allow you to filter on process type and easily calculate the percentage of total duration you are looking for.

           

          Note this query is not in Tableau syntax and I haven't tested it, but it should give you an idea of how to go about it. Let me know if you have follow up questions.

           

          Pedro

          • 2. Re: Show Percentages instead of Mark Labels
            Matthew Hull

            Adam,

             

            There are a few ways to do this, I tried to provide the simplest so that you can easily recreate. Basically, I created a calculated field which got a total of all your measures, set that on the row shelf, and kept your measure names and values as color and label. The I created 3 calculated fields that got the percentage of each process divided by the total. Last, I added percentage formatting to the percentage calcs and replaced the old process measures in the measure value window with the new percentage calcs. Please feel free to reply if you have any questions.

             

            regards,

             

            Matt

            • 3. Re: Show Percentages instead of Mark Labels
              Adam Robins

              Matthew,

              The problem with this approach is that it no longer scales the y-axis properly.  Each bar becomes 3x it's original value.

              Thanks for trying.

              Adam

              • 4. Re: Show Percentages instead of Mark Labels
                Adam Robins

                Thanks Pedro, this is exactly what I was looking for.