One thing I’ve submitted an idea for Tableau Prep (and would love if you voted for it!) is the ability to use Table Calculations, especially Index() and PreviousValue(). This would solve a lot of use cases, including adding row numbers, rank, sort, handling cumulative values, and more. But to compute a rank or sort specifically, there is a work-around that will work in certain cases. Here a possibility for sorting and ranking in Tableau Prep:
Let’s use the familiar Superstore Sample data set which has Sales for Orders made by Customers in various States. Let’s say I want to rank the customers for each state based on the amount of sales. Using Tableau, I have the option to use the Rank() table calculation, and it isn’t too difficult to come up with something like this:
The difficulty with table calculations is 1) you have to set the right addressing and partitioning (not too bad in this case) and 2) you have already gone down several layers of complexity, so deeper analysis is going to be even more complex. What if you could rank the source?
Let’s take the same data set and see how we might achieve ranking in Tableau Prep. If I want to rank by customer within state, here are the steps I might take:
And now, we have something that makes even complex analysis in Tableau so much easier! Do I want to compare summer sales of my top 10 customers per state? Easy! Do I want to look at customers who are top in one state and bottom in another? Easy! There’s no end to the analysis that suddenly became easy because I moved the complexity to the data prep (and Tableau Prep made that easy too! In fact you can download the flow here!)