3 Replies Latest reply on Oct 21, 2016 6:46 AM by Ben Young

# Calculate % of total with a top 10 filter

Hi all,

I'm trying to get a simple text table where I have totals per category, per product per country and I want a second measure column where the % of total is shown. Of course this is simple BUT if i use a top 10 filter the % of total calculation is done on those top 10 rows instead of all rows. Is there a trick to fix this? Currently I've created a RANK on the totals and hide everything except the top 10. Is there a better way?

Thank you,

Richard

• ###### 1. Re: Calculate % of total with a top 10 filter

Hi Richard,

This definitely is possible! There are multiple ways to do this, but my preferred method to do this is using a Level of Detail calculation. If you do not specify a dimension in your LOD expression, Tableau assumes the scope of the entire data set. For clarity, I broke it out into two calculated fields for you.

The first calculated field is called "Total Sales - Irrespective of Filter". The syntax looks like this: { SUM(Sales) }. If you need more help on why this syntax works, let me know. I then used this field in a second calculated field called "Overall % of Total". It has this syntax: SUM(Sales) / Sum(Total Sales - Irrespective of Filter".

The attached workbook has an example built out for you. Hope this helps!

--Ben

• ###### 2. Re: Calculate % of total with a top 10 filter

Thank you Ben. Your method works perfect.

• ###### 3. Re: Calculate % of total with a top 10 filter

Happy to help out