10 Replies Latest reply on Nov 18, 2015 10:31 PM by galaxy.tab

# Sorting Help

Hi,

I am working on the attached file. I want to provide the user a sort option for the "Calc_Sales" calculation. How can I achieve this ?

So I will need on mouse hover over the header a sort option like the sales field.

Thanks

• ###### 1. Re: Sorting Help

What you can do is, click on the column "Calc_Sales" and select any of the sorting options(Ascending or descending).

Please find the attached image for help.

• ###### 2. Re: Sorting Help

I will not be showing the command window in the tooltip.

I want it like the sales column. Is there a way I can achieve it ?

Thanks

• ###### 3. Re: Sorting Help

Hi Galaxy

The calculation... I would use the inbuilt table calculations

Instructions -

Remove the calc_sales field

Right click sales - quick table calculation - % of total

at this point, everything should say 100%

Right click sales again - compute using - sub-category

go back to the left menu, and double click sales, this will add the original field back in, you can swap the ordering as you need.

You should end up like this: (I amended the title % of total)

As for the sorting button (on the 2nd field) - I assume because % of total is derived from sales, only Sales has the sort.

% of doesn't really exist - its calculated from Sales, therefore Sales is the driver for sorts as the % of will naturally follow the Sales sort.

As Rahul mentions above, you can sort via % of total but its in the tool tip, and an extra step...

Hope that helps and is clear!

Cheers

Mark

• ###### 4. Re: Sorting Help

Thanks Mark. So I want to know how to sort sales field in descending order. Since in my data I am not getting the proper sort.

So the sort breakup is based on the category. For every category shown it must sort independent blocks in descending,

• ###### 5. Re: Sorting Help

So the sort breakup is based on the category. For every category shown it must sort independent blocks in descending,

Hi Galaxy

If I understand correctly - you would sort the category field based on descending sales... here is how

Right click the dimension you wish to sort on

then apply the settings, we want descending, based on sum of Sales

press OK

end result

Is that what you wanted?

You can make it as easy or complicated as you wish - you can create ranks (using LOD) and sort based on those... depends on need. This maybe useful > Maintaining Rank and Sort with a Lower Level Dimension

Cheers

Mark

• ###### 6. Re: Sorting Help

Thanks Mark.

So the order of category will be alphabetical. Only the sales will be shown as descending grouped by country.

Hope I am able to explain correctly now.

• ###### 7. Re: Sorting Help

Tableau sorts dimensions in the order they are placed, starting from the left working right

So in the below we would sort category first, then sub-category

So the order of category will be alphabetical. Only the sales will be shown as descending grouped by country.

To get multiple sorts -

Right click Category - sort alphabetically (1)

Next right click sub-category/ country (the 2nd field) and sort that on sales descending (2)

Which gives us the below...

Category Furniture, Office, Tech - alphabetical

Sub Category - 95, 60, 30, 28 descending sales

By doing it that way, if we had a new category/ sub-category it would automatically apply the same sort to the new data to give consistency...

Is that all clear?

Cheers

Mark

• ###### 8. Re: Sorting Help

Not sure if this is relevant, but I wanted to add this link/video on for the thread.

You can have nested sorting by creating a calculated field that combines dimensions, then sorting on that the calculated field.

Tableau Tip Tuesday: Two Techniques for Nested Sorting

Depending on the situation, this can be much easier than implementing Ranks.

Regards,

Rody

1 of 1 people found this helpful
• ###### 9. Re: Sorting Help

Always useful to have your input Rody

• ###### 10. Re: Sorting Help

Thanks Rody , Mark.

Used the nested sort tab. The combined field method works fine for most of the categories. But for some of the categories the sorting is not correct.

The measure in use is from excel and not a direct field but a CASE calculation , when selected displays measure.

Thanks