Adding Dynamic Lines using Set Action in Tableau
When working on a line chart, we might want to add additional lines with sub-category data while keeping the total data in the same chart. For example, in the first image below, we have a line chart showing total sports injuries from 2011 to 2021 in Australia. We can add sub-category data to this line chart by selecting sports in the bar chart on the right side.
As shown in the second image below, selecting Cycling, Wheeled Motor Sports, and Roller Sports in the bar chart adds additional lines to the line chart alongside the total line. This can be achieved by creating a set and a set action in Tableau Desktop.


1. Create an Empty Set:
In the worksheet for the target line chart, create an empty set for the category (e.g., ‘Sport’) and change the line chart color based on this set.

2. Set up a Dashboard Action:
In the dashboard, set up a ‘Set Action’. Navigate to Dashboard > Actions > Add Action > Change Set Values. Select the filter chart in ‘Source Sheets’, set the ‘Target Set’ to the set you created (e.g., ‘Sport Set’), and choose ‘Add values to set’ and ‘Remove all values from set’. Click ‘OK’.

This process allows us to add sub-category data to the set, enabling additional line graphs to appear on top of the original chart.
As a result, the selected categories are added to the previously empty set as shown below, and the lines appear in the original line chart with distinct colors, alongside the total line.
