2 Replies Latest reply on Dec 29, 2018 10:34 AM by Mavis Liu

    Tableau: 100% Stacked Bar Chart

    Diane Lee

      I am new to Tableau, and would like to create a 100% stacked bar chart like in Excel. I managed to stack the 2 different measures into a bar, but I can't get the % right. For the calculated field, I used "Percent of Total" and "Table (down)" but I get 100% for each measure. Refer to image.

      100% Stacked Bar.jpg

       

       

      What I want is Citizen as a % of the sum of Citizen + Permanent. Specifically, Citizen / (Citizen + Permanent)

      How do I get it in Tableau? Thank you

       

      I can't attach my dataset to this post, however have inserted an image of the variables in Excel;

       

      Tableau Dataset in Excel.jpg

        • 1. Re: Tableau: 100% Stacked Bar Chart
          Norbert Maijoor

          Hi Diane,

           

          Find my approach based on 'pivoting' your dataset as reference below and stored in attached workbook version 10.5 located in the original thread.

           

          citizen.png

           

          1. Pivot your dataset first. Pivoting is explained Pivot Data from Columns to Rows - Tableau

           

          2. Drag the required objects to the indicated locations and right click Pivot Field Values > Text menu > Quick Table Calculation > Percent of Total

            and Pivot Field Values > Text menu > Compute Using > Cell

           

          citizen2.png

           

          Hope it helps,

           

          Regards,

          Norbert

          • 2. Re: Tableau: 100% Stacked Bar Chart
            Mavis Liu

            Hi Diane,

             

            Norbett's answer is the best way to do it by pivotting, which you will be able to do if your data source is excel.

             

            The alternative approach is a bit more manual - You'll have to create a new calculated field for the total by adding up your two fields citizen and permanent resident population.

            Then you'll have to find a citizen % by doing sum(cititzen population)/sum(total), and another for the permanent resident %.

             

            Thanks,

             

            Mavis