5 Replies Latest reply on Oct 4, 2016 2:43 AM by Henrietta Bathurst

# Top N by multiple categories

Hi,

I'm looking to create a top N table by two different categories, in this example top N by total incurred (a measure) in each of 7 categories (currently a dimension) (with some extra measure to provide detail but not to be included in the filter).

I feel like this is probably very easy to do but nothing I've tried so far is working, if anyone could provide a solution would be very grateful!

• ###### 1. Re: Top N by multiple categories

Hello,

To combine 2 "Top N" conditions on a measure, the easiest way is probably to create 2 sets based on the dimension you're talking about. Then to combine the 2 set in a "combined set" and to set up what elements you want it to to return.

Create a set:

Repeat the process on the same dimension with another top N logic and then combine the 2 sets together:

Here is a complete explanation of sets in tableau:

Hope this helps!

• ###### 2. Re: Top N by multiple categories

Hi Stephane,

Thanks for your quick reply but unfortunately haven't been able to solve my issue as it won't let me create a combined set?

Any other ideas/if you know what I'm doing wrong in the original method you posted?

Thanks again

• ###### 3. Re: Top N by multiple categories

Hi,

Don't know have you gone through these kb articles or not?

Finding the Top N Within a Category | Tableau Software

Hope this help.

If you still unable to get your desired output then kindly share some sample workbook in .twbx format.

Mahfooj

• ###### 4. Re: Top N by multiple categories

Hi Henrietta, can you share a packaged workbook for us? Or at least a screenshot of what you see?

Until then, what I'd recommend is trying to use a table calculation to get the top N. Try to arrange your rows in descending order and then use a formula like this:

LAST() < [Parameter for N]

Set this to compute along Table Down.

If you can't get the rows to sort properly, you might have to create some sort of combined dimension and put that as the farthest-left pill in the rows shelf.

1 of 1 people found this helpful
• ###### 5. Re: Top N by multiple categories

Hi,

Unfortunately I am unable to share a packaged workbook as the data contains privileged customer information but will try the methods you have all suggested, thank you!