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.

 

 

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.

 

 

The Final Dashboard

 

 

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.

 

Chantel Brooke
Author: Chantel Brooke