In this blog, I will explain how you can add dynamic reference lines to a time series data which will allow the user to see the data relative to a selected reference date.

Step 1: Create your desired chart

I’ve created a chart using Superstore data, looking at Sales over time.

Step 2: Create a Parameter called ‘Select a Reference Date’

For this, you will need to right-click the carrot icon on the Data Pane and click ‘create parameter’. This will open up a dialog box as show below.

Within this dialog box, you will need to name the parameter, select the data type and the display format you want. You can also alter the other settings if you wish.

Once this is created, it will show up as a field under the ‘Parameters’ section in the Data pane. Right click on this field and click ‘Show Parameter’ to view the parameter field on the left side of your visual.

Step 3: Create a Reference line to match this ‘Select a Reference date’ parameter.

Navigate to the Analytics pane on the right side. Under the ‘Custom’ section, drag the ‘Reference Line’ to your visual to match the Order Date. This will open a new dialog box that will allow you to edit the Reference Line as shown below.

Change it so that you can see the date in the view i.e. the date value.

Step 4: Now we need to tell Tableau how to update this reference line

Navigate to Worksheet > Actions > Parameter Actions and set up a parameter action so that the date for the reference line updates when we click different date points on the line graph.

Optional Extra|

(Step 5) : Colour the line graph before and after the selected reference date

Create a calculated field called ‘Before or After Reference Date’, which has the calculation Order date is less than the ‘Select a Reference Date’ parameter. This will create a boolean true or false field. So now, when you drag this calculated field into the colours shelf in the marks card, it colours the view accordingly.

(To remove the highlighting that occurs every time you click on a date, check out my colleague Brandon’s blog on How to stop highlighting when selecting a mark)

Then after a bit of formatting… (and a few calculations)

This is an example where using this dynamic date reference line would be useful
i.e. to view the difference in sales from a selected date (seen in the tool tips)