MIP Logo

Tableau: Highlighting data with dynamic reference lines

This post was originally published on The Data School blog between 2018 and July 2025, before our program was renamed to MIP’s Analytics Career Accelerator. References throughout this article to “The Data School” or “DS” all refer to what is now MIP’s Analytics Career Accelerator. The program, its people, and its commitment to launching outstanding analytics careers remain the same – just under a new name.

If you are having trouble viewing this article, please report it here. 

Highlighting data for the consumer will effectively direct their attention to the data points you want them to focus on. In this tutorial, I will show you how to create a viz in Tableau Desktop using Tableau 2020.4 to highlight data with dynamic reference lines in a scatter plot. The final viz of this tutorial is posted on Tableau Public and can be viewed and downloaded here.

 

Building a scatter plot

 

To start off, pick a dataset of your choice and put one measure on the columns shelf and another measure on the rows shelf. Tableau will automatically aggregate the measures; untick the “Aggregate Measures” option under the Analysis tab.

 

 

As the data is very concentrated around a particular number, untick the “Include 0” box in the “Edit axis” menu by right-clicking the axis. The data is now distributed evenly across the chart.

 

 

Creating parameters

 

The next step is to create parameters. In this case, four parameters will be created for four reference lines respectively. Two on the x-axis (an upper and lower limit) and two on the y-axis (an upper and lower limit). This will create a “box” of data points that will be the focus points.

 

The parameters were created as follows:

 

 

Note that the data type is set to float as the data has decimal places. Tick the “range” option for allowable values and set the current value at the value you want the default reference line to be. Make sure the current value is between the minimum and maximum values. Select the step size that would complement the data set and click OK. Show all the parameters in the view by clicking the down arrow and selecting “Show Parameter”.

 

Inserting the reference lines

 

Next, use the parameters as the reference lines. Click on the Analytics label in the top left corner next to the Data label. Under “Custom” find the “Reference line” option. Click and hold the “Reference line” option and drag it onto the scatter plot. There will be a pop-up menu to choose where on the graph to add the reference line. We want the reference lines to calculate the whole table, therefore just drop the “Reference line” option on either of the measures (two on the x-axis and two on the y-axis) under the “Table” section. In the reference line configuration, select the appropriate parameter as the value from the dropdown list. This step will need to be completed for all four of the parameters respectively.

 

 

Great, now there should be four reference lines (two on the x-axis and two on the y-axis).

 

Highlighting with color

 

The next step is to use color to highlight the data points inside the box. To do this, create a calculated field with the following calculation:

 

 

To make it easier, draw it out on a piece of paper. We want the data that is lower than the upper limit and higher than the lower limit on both the x-axis and y-axis to be highlighted. Click OK and drag this new calculation onto color in the marks card. Then edit the color so that all the “False” and “NULL” data is grey/white/black (depending on the background color) and all the “True” data is colorful (pick any bright color).

 

Tip: If you already have a dimension on color in the marks card, just drag the new calculation onto detail in the marks card and then left-click on the detail symbol in front of it, select color. You now have two dimensions on color in the marks card.

 

Formatting

 

Format the graph to your liking and you’re done! You should have a scatter plot with four dynamic reference lines which highlights the data points inside the reference lines. Use the parameters to change the values of the reference lines.

 

 

For more fun chart tutorials, keep an eye on my other blogs here!

 

Happy vizzing!

 

Share this post