top of page

Exploring Tableau: Dynamic Reference Line

What is a Reference Line?

A reference line in Tableau is simply a line that gets drawn on a chart that represents another measure or point of reference. Tableau Reference lines can be useful in providing context to the related chart. The reference lines are seen as horizontal or vertical lines located at a specific point in a graph. With their help, users can analyze how the results obtained in a certain period are concerning a certain plan or target.

What are reference lines used for?

Reference Lines allow you to place lines on the plot at specific locations to mark important values. You could use these to mark control limits or to indicate a trend line for a set of data.

What is a Dynamic Reference Line?

Dynamic reference lines in Tableau Software offer users more interaction with the analyzes performed. They have the possibility to set the reference line according to other parameters that are not found in the analyzed data set. Thus, the movement of the dynamic reference lines in the graph will always depend on the value of the parameter entered by the user. Similarly, dynamic reference lines are often used to interpret how the results obtained might have been in relation to certain values.

What are the benefits of Dynamic Reference Line?

Dynamic reference lines offer a way to compare with other figures or values that are not found in our data. For example, we can compare the values of sales obtained in a certain period with the number of sales we would have liked to have in our target. Dynamic reference lines help users to be guided in the process of analyzing the data and values obtained. These, unlike the traditional reference lines whose value cannot be modified, offer the users the possibility to modify at any time the value of the parameter that underlies the line. Dynamic reference lines allow users to interact more with their charts. Thus, they can analyze situations in which the plan or values from the established targets would have been different.

Data Source - Sample Superstore

Data Source used is Sample — Superstore.xls from My Tableau Repository\Datasources folder which will be available on your computer as part of the Tableau Public installation.

Data Visualizations

Create a Chart

We will be using Superstore data, looking at Sales over time. Our objective is to add dynamic reference lines to a time series data which will allow the user to see the data relative to a selected reference date.

Create a Parameter

Right-click and drag Order Date to the columns, select continuous weeks and place your sum of sales on the rows. We need to create a parameter that will allow the reference line we put into our view to change dynamically. Select the dropdown in the data pane and choose to create a parameter. Name your parameter 'Select Reference Date’, choose the data type to be Date and in your display format, choose the format as per your preference.

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.

Create a Reference Line

Next, Navigate to the Analytics pane on the left side. Under the ‘Custom’ section, drag the ‘Reference Line’ to your vision to match the Order Date. This will open a new dialog box that will allow you to edit the Reference Line as shown below. In the value dropdown, select Reference Date Parameter. This will ensure that the reference line changes according to the parameter action. Edit label and format for the reference line as per your requirement.

Create a Parameter Action

We need to go to the worksheet tab at the top of your screen, select 'Actions' then 'Add Action'.Next click on ' Parameter Actions' so that the date for the reference line updates when we click different date points on the line graph. Select Run action on select. Select the Reference Date parameter in the parameter target dropdown and your field should be Week(order date) or likewise.

Now when we click on different values within the worksheet, the reference line will change accordingly.

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

I also added sales values for before and after the reference line.

With a few more calculations and formating into a dashboard, we are able to generate the final visualization with a dynamic title added. It shows us the difference in sales from a selected date.

Happy Dynamic Reference Lining!

Thank you for reading, I hope this was helpful!

2,224 views0 comments



bottom of page