Sorting and Top N

Why Tableau sorts the way it does (Ross Bunker post):

Nested Sort

Dynamic sort:

find top N within category (using a set):
can also use Index() instead of a Running Total of # of Records
this also shows how to do a nested sort

Top N within a Category:

Just show top N lines, using filter within IF statement within Top N filter:

Find Top N based on most recent results:

Show Top N, then put everyone else in an “other” group

Long thread on how to do this:

another thread on this:

easy top N and bottom N via v8 sets:


Top N filter and order of filter application

some complex sorting within table calcs

Sorting or ranking within a dimension, with some funky stuff with groups and colors

Sorting an “Other” dimension member at the end of a list, post by Andy Kriebel w/useful comment from Joe Mako at the bottom:

Sorting a view by a table calc

– create the table calc
– create a calculation that uses the table calc to generate something that Tableau’s default sort will work just fine with, e.g. low to high numbers
– put the calculation on the Rows shelf
– set the calculation to Discrete
– drag the blue pill to the leftmost position on the Rows shelf
– uncheck Show Header for that pill

Example from a forum post I created:

Example from Joe Mako, for making a fake color legend that sorts based on a measure:

Standard Rank, Standard Competition Rank

James Baker post:

Show top results with >N% of total, everything else as other

Top 25%/bottom 25%
(Joe’s workbook is another example of “partitioning” by table calculations)\

Another partitioning by table calc workbook:

[loop category=”wikicontent” tag=”sorting,sort,sorts”]
[field title] – Added [field date]

Related posts:

    [loop tag=”sorting,sort,sorts,top-N,bottom-N,hierarchical-sorting,nested-sorting” exclude=”this” relation=”and” compare=”not” taxonomy=”category” value=”wikicontent”]

  • [field title-link][field thumbnail-link]


5 thoughts on “Sorting and Top N

  1. Pingback: Understanding Sorting in Tableau - The Information Lab

Please add your thoughts and perspectives