Top 10 customers filter in Tableau

A top N analysis is one of the most widely spread methods to analyze your customers, sales persons’ performance, the most profitable regions. With Tableau you can easily produce this kind of reports or dashboards. Moreover, you can let your users extend the Top 5 list to Top 10 and the most exciting thing is that you can filter your customers based on their profit and show their sales numbers and vice versa! Sounds great, doesn’t it? Let me show how you should proceed.

1. Create your TOP N list

  1. Start by bringing your customers names on the Row shelf
  2. Add the sum of Sales to your view by double clicking on Sales in the Measures list
  3. Bring the CustomerName into the Filter Pane
  4. Go to the Top Tab
  5. Select By Field
  6. Replace 10 by Create a New Parameter
  7. Choose the Name of your Parameter
  8. Select your Maximum Value
  9. Choose your step value (in our case 1)

Top Customers List creation with a parameter in Tableau

As you can see the Parameter control will be automatically added to your view. You can now easily move from Top 10 to Top 5 customers list by changing your parameter value.

Change parameter value in Tableau

Nevertheless, you can see that our list isn’t perfect. Let do some extra changes:

  1. Sort the sales numbers
  2. Add INDEX() on a row shelf
  3. Transform INDEX into discrete measure
  4. Bring INDEX before Customer Name
  5. Adjust the column’s width
  6. Hide Fields Labels for Rows

Sorting the Customers Sales values in Tableau

Whereas our list is correct, in a real life we are much more specific. We don’t want to have a Top N list based on all the data that we have in our database, we need a Top N list for a specific year or month. That’s why we need to bring an extra filter to our view, the Order Date. As you can see surprisingly our list moved from 10 members to 8! This is precisely a trap I was speaking about in the title of this post.

Order Date and Top 10 trap in Tableau


2. Context filters

Context filters are really great, whereas they improve the performances of your calculations, they explicitly tell to Tableau the order to use while filtering. As you probably know, by default all the filters are treated independently by Tableau. Adding a filter to a context creates a temporary table, it means that your context filter is applied before the others. Let me illustrate it through our example.

Adding year to context  filter in Tableau

As you can see the filter becomes grey, what indicates to us, that it is a context filter and the most important part is that we have our Top 10 customers again!


3. Calculated field

Another way of dealing with our problem is through creating a calculated field. Knowing that we are interested in the ranking based on the last year (2013 in our case), when can proceed as follows

Create a calculated field in Tableau to filter your data

By the way, it goes without saying that you can replace 2013 by a Parameter allowing your user to select year of ranking.




Even though these two methods work well, I personally prefer the second one as it’s more flexible: you can calculate Year over Year growth, bring to your view their previous years’ sales numbers and so on. Eager to find out what kind of solution you use!

Advantages of the calculated field while filtering top 10 customers in Tableau

Spread the love