2 Replies Latest reply on Sep 28, 2018 10:26 AM by Jon Stoessel

    Sorting % of Total (one segment) Stacked Bar Chart

    Jon Stoessel

      Hello Tableau Users,

       

      Just had a quick question in regard to sorting % of Total in a stacked bar chart.  I know there is a trick to this based on what I have read.  Here is what I currently have (see below):

       

      My desire is to sort this view so that each of the blue segment percentages is sorted in descending order within each division.  The stacked bar is showing the % of a specific program/majors students who participated in study abroad for a given academic year.

       

      It seems like I can only sort based on the underlying n's, but can't seem to link the sort to the % of total.

       

      Also know posting an anonymized workbook would help immensely, but I am hoping to find a helper who may have encountered the same issue so I can save some time.

       

      Many thanks!

      Sort % of Total in Stacked Bar.JPG

        • 1. Re: Sorting % of Total (one segment) Stacked Bar Chart
          Naveen B

          Hi jon,

           

          I am assuming Blue as Y and Orange as N and calling this field as Status

           

          1) Create a calculated field name it as sorting

           

          -{Fixed [Division],[Department/program]:MAX(

          if [Status]="Y"

          then

          {Fixed [Division],[Department/program],[Status]:SUM([Sales])}

          /

          {Fixed [Division],[Department/program]:SUM([Sales])}

          END

          )

          }

           

          2) Place this sorting field in between Division and [Department/program] and Uncheck show header

           

          you will get sorted values

           

          Hope this helps

           

           

          Replicates same with Superstore its working fine

           

          Plz mark this answer as correct or helpful to close the thread

           

          BR,

          NB

          • 2. Re: Sorting % of Total (one segment) Stacked Bar Chart
            Jon Stoessel

            Hi Naveen!

             

            This worked perfectly!!  I am still learning my way around using the Fixed function, which I know is primarily learning how dependent they are on filtering (i.e. making sure to add them into the calculation).

             

            I really appreciate your prompt response on this!  Have a great weekend.

             

            Thanks Again,

             

            Jon