8 Replies Latest reply on Nov 30, 2017 3:30 PM by sunil.sachdeva

# Problem with sorting on multiple dimensions

I am having difficulties sorting on the sales per year and per state. Do you have any ideas please?

• ###### 1. Re: Problem with sorting on multiple dimensions

Hi,

one way to do that is:

1. Drag Sales to Rows > Convert to Discrete > Multiply it with -1 > Disable Show header > Place it after Year.

something like:

Please find attached sample workbook, hope that helps.

• ###### 2. Re: Problem with sorting on multiple dimensions

Hi Steve,

You can solve this by using Rank (Rank Calculation). Just make sure that your table calculation is computed Pane Down!

I created an example using Rank Sum(Sales). Please see the below pic and the attached Tableau Packaged Workbook.

Best regards,

• ###### 3. Re: Problem with sorting on multiple dimensions

Dear Sunil,

Many thanks for the tip. I have created the measure as indicated by your goodself, however I cannot move the measure. I am attaching the file.

Thanks,
Steve

• ###### 4. Re: Problem with sorting on multiple dimensions

Hi,

Try these steps:

1.

2.

3.

4.

• ###### 5. Re: Problem with sorting on multiple dimensions

Perfect - that works! :-) however, it seems that I have a problem in my view. I need to create the top 5 products, somehow its not picking the top 5 in descending order. any help appreciated.

• ###### 6. Re: Problem with sorting on multiple dimensions

Hi Steve,

there are various ways to calculated Top N, i used Rank(), please find below steps:

1.  Create a flag for Top N customers using RANK()

2.  Drag it to Filters:

3.  Right click and edit table calculations:

4.  Edit filter and select only True Values:

5.  You would get result as Top5 by State by Year:

Hope that helps.

• ###### 7. Re: Problem with sorting on multiple dimensions

The solution you are looking for can be achieved with either a Rank table calculation or a combined field. The benefit of the Rank is that you can give the user the option of top N filtering. This is how you would be taught during an official Tableau course to solve a nested sorting problem.

Andy Kriebel has captured all the necessary steps in a video and provides an example with both techniques in the following link: Tableau Tip Tuesday: Two Techniques for Nested Sorting

Please let me know if I am understanding anything wrongly regarding your question.

Best regards,

Valantis

• ###### 8. Re: Problem with sorting on multiple dimensions

Thanks Valantis,

I agree with you, i shared using discrete measure tip because TOPN was not mentioned in question (or i misread it ).

however i agree RANK() is better way to calculate TOP N Filtering or TOPN Sorting,

cheers.