2 Replies Latest reply on Dec 14, 2016 7:16 AM by Nick Corbin

# Top N, Percent of Total and Filters

Hi, I have a viz with a table subject to a number of filters. I'm trying to show a top N of count of account numbers with a percent total calculation of the filtered set (not just of the total shown after the filter or filters have been applied).

I thought I could achieve this using context filters, setting a top N in the context filter(s) and a table calculation but I haven't been able to get it to work.

If I use a straight '% of Total' quick table calculation the % returned changes to reflect the total shown as the top N is changed, i.e. the 2nd column in the below where top N = 5 and then top N = 8.

To solve this I thought using a fixed LOD calc would work given the order of operations in Tableau however it doesn't. I've used COUNT([Account No]) / SUM({COUNT([Account No])}) in the 3rd columns and this returns the same % figures as the top N is changed which is good; the issue is that the denominator is always more than it should be, i.e. in the below a context filter has been applied with all values shown so the denominator should return 521,760 to give 100% but it doesn't.

Any help would be much appreciated.

Thanks,

Nick

• ###### 1. Re: Top N, Percent of Total and Filters

Try using the Index technique to do the Top N - this will keep your % static no matter how many of the Top N you choose to display. Business AnalyticsDisplay the top N values in tableau

The link shows how to do it albeit for a more complicated example.

2 of 2 people found this helpful
• ###### 2. Re: Top N, Percent of Total and Filters

Thanks, that fixed the issue, much appreciated