5 Replies Latest reply on Nov 6, 2018 10:09 AM by Paul Wachtler

# Nested Sorting (Ranking the teams)

Hi,

I am new to Tableau, therefore, struggling a bit in implementing my design.

I need to sort the teams (rank) on the basis of PTS.

But if there is a clash in PTS, then the team should be ranked on the basis of %Cal.

I am not sure how to put nested sorting. And is there any other better way other than ranking?

Please refer to the attached file. I have uploaded a dummy data on tableau worksheet.

Thank You.

• ###### 1. Re: Nested Sorting (Ranking the teams)

Amit- I don't believe Excel like sorting is possible in Tableau. You can only sort on one measure. There are workarounds using custom SQL but not sure if that's something you might want to look into and worth the effort. Please feel free to upvote this idea, and go through the responses for some workarounds.

Best,

Shiva.

• ###### 2. Re: Nested Sorting (Ranking the teams)

Thank you for your response. But where can I find the responses for some workarounds?

• ###### 3. Re: Nested Sorting (Ranking the teams)

Nested sorting is available in Tableau version 2018.3.

For the previous versions, there are ways to sort Marks on a view.

Yours,

Yuri

1 of 1 people found this helpful
• ###### 4. Re: Nested Sorting (Ranking the teams)

Yuriy- Your approach is simple and interesting. Thanks for teaching me this.

• ###### 5. Re: Nested Sorting (Ranking the teams)

Hi Amit,

Since this is a multi-level sort, you'll first want to calculate the rank for each team based on PTS.  Use the "rank" calculation- rank(sum(PTS))

Make sure you choose the correct aggregation, I'm using sum in this example but change it to avg, max, min or whatever you need it to be.  That will create a rank for each team as an integer and give teams with the same PTS number the same rank.

Now to add the second part of the sort for %Cal - create a calculated field that adds the rank calculation from before with the %Cal - rank + sum(%Cal)

You can then use this calculated field as your sort - it will still use the original ranks as the initial basis for sorting, but if the ranks are the same, the decimals from the %Cal will come into play for the sort.

Best,

Paul