5 Replies Latest reply on Aug 5, 2016 9:09 AM by Manu Mohan C

Taking Top 'N' after all the Quick filters applied

in my worksheet i have a date field dragged onto filter shelf and top 5 filter applied on a dimension field also in filter shelf. if i filter data using the date filter and i need to view the top 5 of filtered data. without making the date filter as context , is there any other way achieving it?

• 1. Re: Taking Top 'N' after all the Quick filters applied

Manu,

This is probably the most effecient way to do it.  You could also use either the Rank() or Index() functions and filter -- but that would be a late filter, so all the data has to be returned to Tableau first before the Rank or Index function is applied.  It might not be as efficient, but if the number of aggregate rows is small, then it's a viable alternative.

What's the reason you wish to avoid using a context filter?

-Joshua

• 2. Re: Taking Top 'N' after all the Quick filters applied

context filter reduces performance of workbook as it creates a temp table each time the filter changes

• 3. Re: Taking Top 'N' after all the Quick filters applied

how can i achieve that using rank and index function when top 'N' selection is based on a parameter

• 4. Re: Taking Top 'N' after all the Quick filters applied

Manu,

Context filters used to create temp tables, but I don't think this is any longer true with recent versions of Tableau.  Nevertheless, they likely result in rather complex subquerries, which in some cases, may not be performant.  You'll have to determine if it is more or less performant than returning all aggregate rows and then applying the Index() or Rank() function.

To do that, you'd create a calculation that compared the Rank to the parameter value, something like:

Rank(SUM([Field])) <= [Top N Parameter]

Place that on Filters, make sure to set the compute using (use the drop down menu on the field on Filters) to compute along all dimensions, and then keep where it is True.

Hope that helps!

Joshua

• 5. Re: Taking Top 'N' after all the Quick filters applied

Thanks Joshua for your help ,

But the thing is in my filter shelf i have a total of 6 fields out of which 5 are dimensions and one is a measure . so if i add that rank field column to the filter shelf and filter using the measure field filter , would it take the top 'N' values of filtered data?