Sets and Set Actions are one of my favorite areas in Tableau which can add more interactivity and flexibility to your dashboard or chart.

In this blog, I will demonstrate How to create a Dynamic Reference Band using Set Actions. For this task, I am using the famous Superstore dataset and aim to create a dynamic reference band for a selected date range by the end-user.

Step 1: Create Day Dimension using Order Date – click on Order Date dimension -> Create – > Custom date. Then provide the name in Name as Days (given name) and In Detail as Days (as shown below – you can select any based on the viz)

Step 2: Create Day Set – Right-click on created Days dimension -> Create – > Set and name as Days Set and select any dates from the list. This selection can be updated later so you can select any dates in the list. (As shown below)

Step 3: Create a calculated field to get the Maximum date within the set. (This will bring Max date based on the selected date range)

Step 4: Create a calculated field to get the Minimum date within the set. (This will bring Min date based on the selected date range)

Step 5:  Create the Worksheet by Dragging Days into Columns and Sales into rows. Then Right-click and Drag Max Day into Level of Detail and select Max Day (Continuous) and repeat the same for Min Day. (As shown below)

You can change color and remove gridlines for better visibility.

Step 6: Create Reference Band – Go to Analytics Pane -> Drag and Drop Reference Band into Pane – > Select Table and Days Tab

-> In-Band From -> Select Min Day and set Label and tooltip to None

-> In-Band To -> Select Max Day and set Label and tooltip to None (as shown below)

-> In Formatting – > Select desired line pattern and fill color to your reference band – > Click OK

Step 7: Create Set Action – Go to Worksheet Menu -> Actions – > Click Add Action -> Select Change Set Values. Give a name to the Action and select any preferred method for Run action on (I selected the Select option). Select the Target set as the Days set. I selected Assign values to set when running the action and selected Keep Set values when clearing the selection. (As shown below)

Now, you can have a dynamic reference band that allows users to select any date range in their chart to create the band. This will come in handy in financial dashboards to filter out data on selected date ranges.