2 Replies Latest reply on Apr 4, 2016 8:35 AM by Maged Asaad

    Subtotals for Top N List

    Maged Asaad

      In the attached workbook, I used Index, Parameter with nested Sorting to get the TOP N list, but unfortunately Tableau calculate the Subtotals for the Entire Category not for the Top N .


      Is there a way to get the correct Subtotal also the Percentage of the Total Category ??


      Thank you

        • 1. Re: Subtotals for Top N List
          Dan Sanchez

          Hello Maged!


          I think I've got a solution for us but it's a bit manual and doesn't allow the interactivity of switching the number of Top N rows after initial configuration.  Hopefully that's ok.


          The first step is to create sets for each of the categories.  We can do this by clicking the header for each category to select all marks and then click the Create Set button.


          Once we've got the sets created we then need to create Combined Sets to pull all the results together.  We can only combine two sets at a time though.


          After creating the first Combined Set of Furniture + Office Supplies, we'll create the next combined set using Technology and the Furniture+Office Supplies set:


          We can then bring our final Combined Set to the Filters shelf, right-click, and select Show Members in Set:


          We now will have the Top 5 with subtotals for just those 5.  I also added the Percent of Total calculation into the viz.


          The drawback to this solution is that if you want to see more (or less) Top N records, you'll have to go back and create the sets again from the beginning.  Additionally, since the sets are manual sets and not calculated sets, This solution might be best suited for looking at historical data since the sets won't update dynamically when new data comes into the data source.


          Attached is a revised copy of the workbook.  Hope this helps!



          • 2. Re: Subtotals for Top N List
            Maged Asaad

            Thank you Dan for taking the time to write this solution.

            As you mentioned; this solution is best for looking at historical data, unfortunately mine is refreshed weekly I don't think it suits me.

            I still believe that there's a way to make it dynamic and also with the Top N parameter changes to take effect.