KNOWLEDGE BASE

Sorting a Legend Independently from the Order of Fields in a View


Published: 15 Jul 2013
Last Modified Date: 12 Jan 2018

Issue

The fields in the color legend of a worksheet cannot be sorted in a different order than the dimension fields reflected in the view.

Environment

Tableau Desktop

Resolution

Depending on how the view is built, the best workaround will vary. Both solutions are demonstrated in the attached workbook.

Option 1

  1. Drag [Sales] to Columns.
  2. Drag [Category] to Rows.
  3. Right-click [Category] in the data pane and select Duplicate.
  4. Drag [Category (copy)] to Color on the Marks card.
  5. Right-click [Category] on the Rows shelf and select Sort…
  6. In the Sort dialog, select the desired sort order and click OK.
  7. Right click the color legend and select Edit Title…
  8. In the Edit Legend Title dialog, delete (copy) and click OK.
 

Option 2 (For a stacked bar chart)

Step 1 - create the view

  1. Create a worksheet for the stacked bar chart and name it something like "Stacked Bar Chart - just bar chart"
  2. Drag [Sales] to Columns.
  3. Drag [Category] to Rows.
  4. Drag [Sub-Category] to Color on the Marks card.
  5. Right-click [Sub-Category] on the Marks card and select Sort…
  6. In the Edit Legend Title dialog, delete (copy) and click OK.
  7. Create a worksheet for the color legend and name it something like "Stacked Bar Chart - just color legend"
  8. Drag [Sub-Category] onto Color on the Marks card
  9. In the drop-down on the Marks card, select Polygon.

Step 2 - create a dashboard

  1. Create a dashboard.
  2. Drag "Stacked Bar Chart - just bar chart" onto the dashboard.
  3. Remove the color legend that is automatically added.
  4. Drag "Stacked Bar Chart - just color legend" to an inconspicuous place on the dashboard.
    Tip: Consider making this worksheet floating.
  5. Right-click the "Stacked Bar Chart - just color legend" worksheet on the dashboard and select Hide Title
  6. In the drop-down at the top of the dashboard select Entire View. This will prevent scrollbars from appearing if the worksheet is sized down very small.
  7. Optional: Right-click the color legend and check Highlight Selected Items.

 

Cause

The sort order is set for the dimension at the worksheet level, thus the dimension members will be sorted the same wherever the dimension is used in the view.
Did this article resolve the issue?