## Prevent Tableau from Recalculating your Table Calcs after Filtering

by Gauthier Bonnot

Recently I was having a chat with Anna Noble while she was trying to solve a Tableau issue I had already encountered in the past without finding the solution. It implied keeping a table calculation (i.e. a rank) from recalculating after it had been filtered.

Let’s say you are interested in building a ranking of your customers given their aggregated sales and want to have a filter option allowing the isolation of specific customers. Once you have built the view, if you filter down to one customer, you will notice the ranking will be lost and only show 1.

The reason why this is happening is due to Tableau’s order of operations. Rankings are table calculations; therefore they are applied at the end of the process. So if you apply a filter on only one customer, Tableau will calculate the ranking with only one value. Below you can find a visualization of Tableau’s order of operations, If you want to know more about it I encourage you to have a look here.

The workaround is very simple; you need to turn your filter into a table calculation so it gets applied at the end, effectively after the ranking. After she found the solution, Anna had pointed me to a great video made by Chris Love explaining how to proceed. You just need to use the following calculated field:

#### LOOKUP(ATTR([Customer Name]), 0)

This formula will return customer names, but it will do it through a table calculation. By dragging the newly created field into the filter shelf you will then be able to filter your customers while maintaining their rankings.

Super simple and logical, it will work with any other table calculations such as percentage of total as Chris illustrates it in his video.

Stay tuned for more Tableau and Alteryx tips!

* Feature Image designed by Freepik

Gauthier Bonnot

Reflections and Advice for Future DSers

Sun 03 Jun 2018

Plot two measures on your hexmap

Sun 13 May 2018

Dashboard Week Day 4