Analytics tricks – Sorting by multiple dimension using parameters in Tableau

How does one sort a view by more than one dimension/measure in Tableau? The following steps will help you accomplish this :

Consider the following Sales Data

shop_name category product price
Reliance Food OAT 100
Reliance Digital Electronics Laptop 25000
Croma Electronics Speaker 700
Reliance House Hold Mob 150


Create Parameter- 

      1.  Right Click in Data Pane and select Create Parameter
      2. Dialogue Box will appear. Select the following and then click OK
        •             Name : Sort By
        •             Data Type : String
        •             Allowable Values : List
        •             In the list enter : Shop Name, Product, Category
      3. Right Click on the parameter created and select “Show Parameter Control”

Create Calculated field for Sorting –

        1. Right Click in Data Pane and select Create Calculated Field
        2. Type the following formula and type the name as sort_by_dimension and then click OK.

if [Sort By] = ‘Shop Name’ then [shop_name]
elseif [Sort By] = ‘Product’ then [product]
elseif[Sort By] = ‘category’ then  [category] end

Implement in View – 

      1. Drag the required dimensions to row – In this case it could be Shop Name, Product, Category.
      2. Add measures like quantity, sales to column
      3. Drag sort_by_dimension to Row – placing it at left most
      4. Right Click on sort_by_dimension and fill in the following values on the dialogue box –
        Sort order : Ascending
        Sort by : Alphabetic
      5. Right click on sort_by_dimension and then un-check Show Header

Now, change in values of parameter will change the sorting order.

By Monu Agarwal
Coviam Technologies

Also published on Medium.