17 August 2023
Displaying the top or bottom values in your data is a common task in Tableau. The Top N feature allows you to quickly filter your views to the most or least significant rows.
In this article, you'll learn multiple methods for showing the top and bottom records in Tableau Desktop. The material from this article is part of our tableau course. JBI Training can supply training in Tableau to your entire team.
Analysing the top and bottom performers in your data is crucial for many business objectives. For example:
Tableau has built-in functionality for easily filtering your views to the Top or Bottom N records according to a measure. You can also use table calculations or level of detail (LOD) expressions to compute a rank column and display the top values.
We'll cover the pros and cons of each approach. Let's get started!
The easiest way to filter for top values is by using Tableau's Top N filter on the Filters shelf:
For example, to show the 10 customers with the highest sales:
This will dynamically filter the view to only the top 10 customers by sales each time you open the workbook.
You can customize the filter to change:
For example, you may want to use a custom rank measure that handles ties, rather than the default sum.
Table calculations offer more flexibility for computing a rank column to find the top values. You can then filter on the new rank field.
Common ranking table calculations:
Steps to filter top N with table calcs:
RANK([Sales])
For example, to find the top 10 states by sales with ties:
// Table Calculation
RANK_DENSE(SUM([Sales]))
Table calculations offer more ranking options compared to the built-in filter. However, they can impact performance as the calculations occur dynamically on extract refresh.
When you need to rank large datasets, level of detail (LOD) expressions can optimize performance.
LODs fix dimensional values so calculations run at the aggregate level. Steps:
FIXED
to determine your partition.RANK
functions to calculate rank.TOPN
or BOTTOMN
.For example, to find the top 10 categories by sales:
// LOD Expression
{FIXED [Category]: TOPN(10, SUM([Sales]), [Category])}
LODs allow ranking calculations to be computed during extract refresh rather than live. This boosts speed with large or complex data.
Method | Pros | Cons |
---|---|---|
Top N Filter | Simple setup | Limited options for rank measure and ties |
Table Calculations | More ranking flexibility | Can cause slow extract refreshes |
LOD Expressions | Fast ranking of large data | Requires specific LOD syntax |
Top N filter - Great for quick analysis with the default sum.
Table calcs - Allow custom rank measures and tie handling.
LODs - Optimize ranking performance on large datasets.
Choose the technique that meets your specific needs.
Once you've filtered to the top records, effective visualization can draw attention to the top results.
Bar charts are a great way to showcase top values using bar length. Sort bars descending to emphasize the top items.
Highlighting like colour or reference lines can call out top results clearly.
Labels displaying ranks or record counts make it easy to identify top and bottom values at a glance.
Finding the most and least significant values in your data is key for many business analytics use cases. Tableau provides several options for filtering to the Top N records:
Use the right method for your specific needs. Effective visualization brings out the top results.
You now have the skills to analyze and showcase your top-value data in Tableau!
How do I show top 5 instead of top 10?
In any method, simply change the number of rows to display. For example, set the Top N Filter to 5 rows or use TOPN(5)
in a LOD expression.
What if I have multiple records tied at rank 10?
The built-in filter will include all tied records. For precise control, use table calcs or LODs to configure the exact tie behavior you want.
Can I create a percent of total rank measure?
Absolutely! Write a custom table calculation using the SUM() and WINDOW_SUM() functions to calculate percentage of total.
This article is part of our ongoing series of how-to articles related to Tableau. You might also enjoy how to concatenate in tableau or our article or how to create top n parameter in tableau
CONTACT
+44 (0)20 8446 7555
Copyright © 2024 JBI Training. All Rights Reserved.
JB International Training Ltd - Company Registration Number: 08458005
Registered Address: Wohl Enterprise Hub, 2B Redbourne Avenue, London, N3 2BS
Modern Slavery Statement & Corporate Policies | Terms & Conditions | Contact Us