Legend in Tableau

What is a legend in Tableau?

A Tableau legend is a visual feature that provides context to your data visualization by explaining the data elements used in the visualization. These legends explain the meaning of different colors, sizes, shapes, or labels used in the visualization to provide the end users with a meaningful context about the visualization and make data interpretation more transparent and simple.

Tableau supports four different types of legends in any visualization: color legend, shape legend, size legend, or label legend. A sample Tableau legend looks like the one provided below.

Legend in Tableau - Intro
Key Takeaways
  • Tableau legend is a visual feature that adds context to your data visualization by explaining the data elements used in the visualization.
  • These legends explain the meaning of different colors, sizes, shapes, or labels used in the visualization to provide the end users with a meaningful context about the visualization and make data interpretation more transparent and simple.
  • Tableau supports four different types of legends in any visualization: color legend, shape legend, size legend, or label legend.
  • You can create, edit, delete, hide, unhide, and float a legend in Tableau
  • You can also create a legend for a calculated field in Tableau and show legend in Tableau.

How to create a legend in Tableau?

To create a legend in Tableau, follow the step-by-step instructions outlined below:

Step 1: Create a Tableau visualization using the data source you have imported into Tableau.

Step 2: Depending on the type of legend you want to create, follow the steps appropriately

  • Color Legend – Drag the field on which you want to create a legend to the Color on the Marks card. Tableau will create a color legend as highlighted below.
Color Legend
  • Size Legend – Drag the field on which you want to create a legend to the Size on the Marks card. Tableau will create a size legend as highlighted below.
Size Legend
  • Shape Legend – Drag the field on which you want to create a legend to the Shape on the Marks card. Tableau will create a Shape legend as highlighted below.
Shape Legend

How to edit legend in Tableau?

To edit the legend in Tableau, follow the steps outlined below:

Step 1: Right-click on a legend you want to edit.

Step 2: Depending on the type of legend, you can edit the changes.

  • Color Legend
    • Choose Edit Colors from the context menu.
Legend in Tableau - Edit Colors
  • Select a data item on the left side of the screen and then choose the color palette you want to apply to that data item. Click on OK to save the changes.
Edit Colors - palatte
  • Size Legend
    • Choose Edit sizes from the menu.
Legend in Tableau - Edit Size
  • In the Edit Sizes window, specify the range.
Legend in Tableau - Edit Size - Range
  • You can tick the Reverse check box, which will reverse the size legend as shown below.
Legend in Tableau - Edit Size - Reversed
  • Shape Legend
    • For Shapes, choose Edit shape.
Legend in Tableau - Edit Shape
  • In the Edit Shape window, select a data item and choose the shape you want to assign.
Legend in Tableau - Edit Shape - choose shape

Step 3: Once the changes are made, you can view them in the legend in the Tableau view.

How to delete a legend in Tableau?

To delete the legend in Tableau, below are the steps you may follow:

Step 1: Open a Tableau visualization with a legend in your Tableau Desktop.

Step 2: Right-click on the field that has a legend in Tableau and choose Remove. Alternatively, you can simply drag the field out of the Marks pane.

Legend in Tableau - Delete - Remove

It will delete the legend in Tableau as shown below.

Legend in Tableau - Delete - Graph

You can follow the same process for other types of legends, such as, Size, Shape, etc.

How to hide and unhide legend in Tableau?

To hide a legend in Tableau follow the steps provided below:

Step 1: Click on the down arrow visible on a legend pane in Tableau view.

Legend in Tableau - hide & Unhide - Step 1

Step 2: Click on the Hide Card option from the context menu.

Legend in Tableau - hide & Unhide - Step 2

You will no longer be able to see the legend in the Tableau view.

Legend in Tableau - hide & Unhide - Step 2 - no legend

To unhide a legend, you may follow the below steps:

Step 1: Navigate to Analysis – Legends – <Choose the legend>.

In this case, we want to unhide the color legend in the view. Hence, choose the Color Legend (Category) option.

Legend in Tableau - Unhide - Step 1

It will show legend in Tableau for the color categories, as shown below.

Legend in Tableau - Unhide - Step 1 - show legend

The same process can be repeated for other types of legends as well.

How to Float Legend in Tableau?

The floating of the legend is only supported in the Tableau Dashboard. This option is not available for Tableau worksheets.

To float Legend in the Tableau Dashboard, follow the steps below:

Step 1: Create a Tableau dashboard by dragging the Sheets to the Dashboard view.

Legend in Tableau - Float - Step 1

Step 2: Select a legend you want to float.

Float - Step 2

Step 3: Click on the down arrow and select Floating from the drop-down as shown below.

Float - Step 3

Now, you float the legend as you choose in the Tableau Dashboard view.

Legend in Tableau - Float - Step 3 - float legend

Examples

In this section, we will examine a few examples of adding legends to the union operations in Tableau using different datasets for demonstration purposes.

Example #1 – Add a Color Legend in Tableau

In this example, we will demonstrate how to add a color legend to Tableau. To demonstrate this example, we have leveraged the Apparel Store Sales dataset, which contains the sales details of different apparel across different categories of products, along with financial details.

To add a color legend in Tableau, follow the instructions outlined below:

Step 1: Import the Apparel Store Sales dataset into Tableau using the Tableau interface. The imported data is visible in the Data Source tab.

Example 1 - Step 1

Step 2: In a new worksheet, drag Revenue to the Columns shelf and Age Group and Category to the Rows shelf. Tableau will create a bar chart in the view as shown below.

Example 1 - Step 2

Step 3: Drag the Category to the Color on the Marks card. Tableau will add a color legend to the Category as shown below.

Legend in Tableau - Example 1 - Step 3

Step 4: Right-click on the legend and choose Edit Colors.

Example 1 - Step 4

Step 5: Select a data item in the list on the left, and then select a new color in the palette on the right.

Example 1 - Step 5

Step 6: Select OK. Tableau has updated the color legend based on your selection.

Legend in Tableau - Example 1 - Step 6

Example #2 – Add a Size Legend in Tableau

In this example, we will demonstrate how to add a size legend to Tableau. We have used the Customer Spend dataset, which contains the customer details along with the transaction details across different transaction categories.

To add a size legend in Tableau, follow the step-by-step instructions outlined below:

Step 1: Connect the Customer Spend dataset with Tableau using the Tableau interface.

Example 2 - Step 1

Step 2: Create a data visualization by dragging the Transaction Value to the Columns shelf and Transaction Category to the Rows shelf as shown below. Then, drag the Transaction Category to the Size on the Marks card. Tableau will display the Transaction Category legend to the right of the view.

Example 2 - Step 2

Step 3: Right-click on the legend and choose Edit sizes.

Legend in Tableau - Example 2 - Step 3

Step 4: In the Edit Sizes [Transaction Category] screen, adjust the Mark size range and click on OK.

Legend in Tableau - Example 2 - Step 4

Example #3 – Add a Shape Legend in Tableau

In this example, we will demonstrate how to add a shape legend in Tableau. We have used the Levis Sales Database dataset which contains the sales details across different product categories across different retailers, regions, States, and Cities along with the financial details.

To add a shape legend in Tableau, follow the step-by-step guide below:

Step 1: Connect the Levis Sales Database with Tableau using the Tableau interface to import the data.

Example 3 - Step 1

Step 2: Drag Region to the Columns shelf and Retailer and Product to the Rows shelf.

Example 3 - Step 2

Step 3: Click on the Marks dropdown and choose Shape from the available values.

Example 3 - Step 3

Tableau will add shape to the visual, as shown below.

Legend in Tableau - Example 3 - Step 3 - add shape

Step 4: Drag the Sales Method to the Shape on the Marks card. Tableau will display the Sales Method shape legend in the view as shown below.

Example 3 - Step 4

Step 5: Right-click on the shape legend and choose Edit shape from the context menu.

Legend in Tableau - Example 3 - Step 5

Step 6: In the Edit Shape [Sales Method], select the data item to change the shape.

Legend in Tableau - Example 3 - Step 6

Tableau will reflect the changes in the shape legend as shown below.

Legend in Tableau - Example 3 - Step 6 - reflect shape

Example #4 – Add a Label Legend in Tableau

In this example, we will demonstrate how to add a label legend to Tableau. To demonstrate this example, we used the Oil_Production_Statistics dataset, which contains oil production statistics across different countries and product categories.

To add a label legend in Tableau, follow the below instructions:

Step 1: Import the Oil_Production_Statistics dataset into Tableau. You can view the imported dataset in the Data Source tab.

Example 4 - Step 1

Step 2: In Tableau, Drag Value to the Columns shelf and Product to the Rows shelf. Then, drag the Value to the Label on the Marks card. Tableau will create a bar chart in the view, as shown below.

Legend in Tableau - Example 4 - Step 2

Step 3: Drag the Product to the Color on the Marks card. Tableau will add a label legend to the view as shown below.

Legend in Tableau - Example 4 - Step 3

Step 4: Right-click on the label legend and select Edit Colors.

Legend in Tableau - Example 4 - Step 4

Step 5: In the Edit Colors [Product] screen, select the data item and choose Color Palette from the screen on the right. Click on OK.

Example 4 - Step 5

Tableau will update the label legend in the view, as shown below.

Legend in Tableau - Example 4 - Step 5 - Label

Important Things to Note

  • You can’t edit shape legends using Tableau Readers.
  • Depending on the visualization requirements, you can also use one of the legends, e.g., Color, Size, Shape, or all the legends in your visualization.
  • To keep the legends up-to-date, it is recommended that you update the underlying data regularly through the automatic refreshing schedule.
  • If there are multiple legends in a visualization, you can reshuffle the legends at your convenience.

Frequently Asked Questions (FAQs)

1. Why isn’t my Legend updating when I change data in Tableau?

There can be various reasons why your legend may not be updated when you change data in Tableau. Some of the possible reasons include:

The data source is not refreshing, though the underlying data may have changed. Consider either manual refresh or scheduling the refresh frequency.
 The availability of a filter may result in legend not updating. Check if the filter is configured correctly.
Sometimes, legends that are part of a dashboard may not refresh because the dashboard does not update the data changes. Ensure the dashboard is auto-refreshed with any changes to underlying datasets.
If you still need help with your legend update, search the Tableau community forums for solutions to your specific problems.

2. Can I create a Legend for a calculated field in Tableau?

Yes, you can certainly create a legend for the calculated field in Tableau. All you need to do is drag the calculated field to the Color, Shape, Size on the Marks pane and Tableau will create a legend for you.

3. How do I handle legends for aggregated data in Tableau?

For aggregated data, Tableau will create a quantitative legend representing a range of values. Choose the Format Legends option to apply customized formatting as appropriate to your visualization.

4. Can I add Legends to a Tooltip in Tableau?

While you can’t directly add legends to a tooltip in Tableau, there are some workarounds

Create a Separate Sheet for Legend. Insert the sheet as a legend along with the original sheet in the tooltip.
Manually add the legend symbols using ALT codes.

Recommended Articles

Guide to What Is Legend in Tableau. We learn how to create, edit, hide, unhide and delete legends in Tableau along with detailed examples. You can learn more from the following articles.

Tableau Chart Types

Tableau Alerts

Tableau Data Blending

Reader Interactions

Leave a Reply

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