MIP Logo

Using the Distance Calculation to Create a Dynamic Buffer Around a Point in Tableau 2019.3

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. 

In September 2019 Tableau released version 2019.3 where distance calculations were introduced. Adi Mcrea from the Data School UK was visiting us here in Australia and she gave us a great session on Spatial Analytics. One of the things she covered was the new distance calculation and how it can be used to create a buffer zone around a point.

 

So what does the Distance calculation do?

The Distance calculation makes it easy to measure the the distance between two spatial centroids or points. If your data set is a flat file with for example only latitude and longitude fields these can be converted using the MakePoint calculation.

One great use of this calculation is to create a buffer zone or radius around a point. This can be used to determine how many data points are within a set distance from the given point. This can also be made dynamic using parameter actions to be able to select a different point on the map and have the buffer zone change.

 

Creating it in Tableau

For this example I used a database of cities in the United States which had the longitude and latitude of each city. The data set can be found here.

First a parameter was created for the chosen city’s latitude and longitude. Then the MakePoint calculation was used to make a spatial point for the chosen city as well as each individual city. Finally the Distance calculation is used to find the distance between each individual city and the chosen city. The units can also be specified, in this case I used km.

 

 

Creating Parameter Actions to Dynamically Update the Chosen City

To have the dashboard update as a new city is clicked on I created several parameter actions. The most important ones are the one that updates the chosen city’s longitude and latitude. This will update the values used in the distance calculation. The rest of the dashboard actions were used for labeling and formatting.

 

Buffer Calculation in the calculation window

 

Using a Level Of Detail Calculation to Count the Number of Cities in the Buffer Zone

Then to count the number of cities in the buffer area, a Level of Detail calculation can be used. I also used a parameter for the size of the buffer zone so it could be adjusted using a slider.

 

Feature Engineering - Cyclical Variables

 

The Final Dashboard

 

Zoomed in view of buffer zone and centroids

 

Unfortunately the distance calculation is only supported with a live connection and therefore the workbook cannot be posted on Tableau Public. However I have posted a working version showing the functionality of the dashboard calculating the distance using a pre Tableau 2019.3 calculation using trigonometry. Feel free to view it or download it from Tableau Public here.

 

Share this post