How to calculate distance between two points on a map in Tableau Software – Skill Pill Video

calculate distance tableau software

Winter holidays are here and even if the global pandemic does not offer us so much mobility in terms of travel, surely many of us will at least visit our families or go on a short vacation, locally. On the other hand, also during this period, retail companies are in one of the busiest periods of the year. Now, more than ever, most of us choose to shop online, both for the gifts of our loved ones and for us. Today we will discuss about how to calculate distance in Tableau which allows us to find out the distance between two or more points on a map.

I chose this topic because in these busy periods for transportation companies or for eCommerce stores, transport workflows and deliveries efficiency are extremely important. For this we must have an overview of delivery points and final destinations. It is also important to know the distances we must cover between the final delivery points to properly optimize the routes.

How to calculate distance in Tableau

Calculate distance in Tableau is a very useful starting point for departments that deal with optimizing routes for agents. Moreover, this type of calculation is used in geospatial analyzes to indicate the distances between several points and to make decisions regarding the costs necessary to cover them. Also, distance calculation in Tableau can be used in analyzes to determine the profitability, which is always closely related to the costs of our organization. For example, if the distance between two points on the map (warehouse and customer destination) is bigger, it is very likely that the costs will increase in direct proportion to it. Thus, the profitability will be lower, and the distance may not be so profitable.

On the other hand, calculate distance in Tableau can be used even for personal purposes. As long as our data set includes latitude and longitude information, we can easily explore a certain map and the distances between the points on it. You may want to find out the distance between the tourist attractions open during this period. Or maybe you are interested in what is the distance of the best hotels from the slope you are going to reach. Calculate distance between data points in Tableau is a useful feature for both professional and personal purposes and can be a valuable method for exploring interesting geospatial information.

In the lines below we have described all the steps you need to go through to use the distance calculation feature in Tableau. We encourage you to watch the video to see the final result.

Step 1: Connect to data

→ In Tableau Desktop, you can use any datasource that has at least 4 coordinates columns, in this case you can use the All flights datasource from Tableau website

Step 2: Create the visualization

→ Create a new calculated field for the geometry of the origin point: MAKEPOINT([Lat],[Long])

→ Create a new calculated field for the geometry of the destination point: MAKEPOINT([Dest Lat],[Dest Long])

→ Create a new calculated filed for the distance between the 2 points: MAKELINE([Pct1],[Pct2])

→ Double click on the field from pt 3

→ You could add destination or origin country on color for an easier understanding of data

→ If you want to add a radius around your points, you can do this by creating a field with the formula BUFFER([Pt1 sau Pt2], 100,’km’) – you can use any measure of the distance

→ Duplicate Latitude on rows and select Dual Axis

→ From the marks menu of the second axis, eliminate the 2 fields and double click on the Buffer field to add the circles into the view

By Andrei Stan

Download Tableau Software