For anyone attending a Tableau training on the second day, we will often teach how to create a Top N filter. This is a very commonly used tip by Tableau authors. Often the analysis asks us to filter the data by the top performers and to allow our end users to decide which N they want to see.

Top N in Tableau

Sometimes, though, we will want to give the end users some extra flexibility. Instead of seeing just the top performers, we want to also allow them to select the bottom ones.

To do that, we just need to follow three steps:

  • Create a String parameter allowing the end user to select Top or Bottom
  • Create a calculation like the one below
  • Add the calculated field to the Filter shelf and set it to True

Top and Bottom Calculation in Tableau

What the calculation does is to look for the Top/Bottom parameter, and if it is the Top, then a Boolean field will show true for all the all the values equal or lower than the number in the Top N. (-Sales) inverts the values and therefore filters for the top values, considering that we are now looking at negative values.

In the view, however, we keep the Sales and not the negative values.

Final view in Tableau

This is a very quick tip that I hope you find useful. You can see how it works in the actual Tableau dashboard below. Thank you for reading.

More from the Author

David Pires

Senior Analytics Consultant