How to Create a Parameter Control In Tableau to Sort by Dimension

You can easily sort your data by different dimensions when you use a parameter control. For example, you have several dimensions—Item, Category, Department, and Region—and you want to be able to select the dimension from a drop-down list by which to sort the data. To do this, complete the following tasks:
  • Create a parameter with the dimension values you want to sort by and show the parameter control in the view.
  • Create a calculated field used to perform the sort.
  • Build the view.

Step 1: Create a parameter

  1. Open Tableau Desktop and connect to the Sample - Superstore data source.
  2. Right-click in the Data pane, and then select Create Parameter.
  3. In the Create Parameter dialog box, do the following:
    1. Name the parameter. For this example, name the parameter Sort By.
    2. For Data Type, select String.
    3. For Allowable values, select List.
    4. For Value, enter the following list of values: Department, Category, Item, and Region.
    5. Click OK.
  4. Right-click the parameter, and then select Show Parameter Control.

Step 2: Create a calculated field

  1. Select Analysis > Create Calculated Field.
  2. In the Calculated Field dialog box, do the following:
    1. Name the calculated field. For this example, name the calculated field Sort by Dimension.
    2. In the Formula text box, build the following calculation:
      CASE [Sort By]
      WHEN 'Department' THEN [Department]
      WHEN 'Category' THEN [Category]
      WHEN 'Item' THEN [Item]
      WHEN 'Region' THEN [Region]
      END
  3. Verify that the calculation is valid, and then click OK.

Step 3: Build a view

  1. Drag ItemCategoryDepartment, and Country/Region to the Rows shelf.
  2. Drag Sales to the Columns shelf.
  3. Drag Sort by Dimension to Rows and then drop it in front of Item.
  4. Right-click Sort by Dimension on Rows, and then select Sort.
  5. For Sort order select Ascending, for Sort by select Alphabetic, and then click OK.
  6. Right-click Sort by Dimension on Rows, and then clear Show Header.
You can now use the Sort By parameter control to select the dimension you want to sort by.