Sorting in Tableau

Basic sort

Right click on the discrete1 field in the rows or columns shelf

1 Sort can be performed only on discrete fields or measures which is converted to discrete

sort1

The discrete field can be sorting by

  1. Data source (if the field is pulled from a SQL data, this order is based on sort orders applied to this relation)
  2. Alphabetically
  3. Based on another Field across different aggregation level

sort1

Non-Nested Sort

The nature of the sort function in Tableau is that sorting is done at the content level.

When a sort is done based on the SUM(profits) descending, you can notice that CENTRAL market is at the top. This because the aggregate SUM of CENTRAL is the maximum. Similarly COFFEE product type as a MAX of SUM(PROFIT) arranged descending. Hence it is at the top across all the Markets. The results are not sorted based on the Markets but to the entire context.

This is the default behavior within Tableau.

 

sort2

Nested Sort

If the results is expected to be sorted based on the markets,  we have to create a nested sort using a work around.

In the dimensions pane, press the CTRL key, and then select the dimensions. Right-click on e of the selected fields and click on Combine Fields option. The newly combined field, Market & Product Type is created. Drag this field to the Rows panel and set the sort options. We will get a nested sort output.

sort3

Selected Sort

With the previous sort you can add more measures but the results will still be still sorted by PROFIT

sort4

 

 

 

Print Friendly

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *