How to create path lines on a Map in Tableau

In Tableau, we can draw a line between two points, to display distances between them. In this blog we will see how to create path lines on a Map in Tableau.

We will be using functions such as MakePoint,MakeLine and Distance.

To explain this concept, I will be creating a Map which will display the distances to Ohio Computer Academy center from various cities in Ohio.

Steps – how to create path lines on a Map in Tableau

1. Data preparation

I have prepared the following dataset, which has the Training provider’s Name, Address and Latitude/Longitude. I also have all the zipcodes of OH and corresponding Latitudes and Longitudes.

Data Preparation
Dataset used in the example

2. Load data in Tableau

Launch Tableau and connect to your dataset which can be in xls, csv or anyother desired format. Click here to learn how to connect to data sources in Tableau.

3. Creating calculated fields.

Create two calculated fields using the MakePoint function. This function will create points for the Training Provider and Recipients. MakePoint function uses the Latitudes and Longitudes.

Creating Calculated Fields In Tableau
Calculated field for the Training Provider Point

Similarly, we will create a point for the Recipients

Calculated Field For The Recipient Point
Calculated field for the Recipient point

4. Create a line.

Create a line between the Training provider point and the Recipients point by using MakeLine function.

Makepoint Function
Create a line between two points

5. Creating Distance.

Create another calculated field to calculate the distance between the two points by using the function Distance.

map-in-tableau
Calculating distance between the two points

6. Create a visualization.

  • From the data pane, double click on Longitude(generated) and Latitude(generated) fields.
  • Drop Recipient City on the Detail (under Marks), this will give us symbol map for Ohio.
  • Drop MakeLine calculation on the Detail (under Marks).
  • Drop Training Provider City on the Detail.
  • Drop Distance calculation on the Tooltip.
Create Path Lines
Marks card settings on the first Latitude

7. Visualization additional steps.

  • Make a copy of the Latitude on the Rows, by pressing ctrl button on the keyboard, selecting Latitude on the Rows and dragging it over to right.
  • On this copy of the latitude, place Recipient City, Training Provider City on the Detail and Distance on the Tooltip.
  • From the Marks, choose Shape, if you want to use any custom shape for the Training Provider. I am using a custom shape, you can leave it blank or use a circle.
map-in-tableau
Settings on second Latitude

8. Final visualization output.

Now selecting the Recipient city on the filter, will show the lines from Ohio Computer Academy to the selected city and the distances.

Create Path Lines
Final output of the Map, display the lines between the two points and the distance between them.

To get more tips and learn Tableau from scratch, explore the book Dashboarding with Tableau.

If you have any questions, please comment on the blog.

To explore more on Tableau, visit Ohio Computer Academy/Tableau and also LearnTableauPublic.com

Tableau Training


About the Author

Chandraish Sinha has  20+ years of experience in Information Technology. He is an accomplished author and has published 11 books covering Business Intelligence related topics such as, Tableau,Power BI, and Qlik. Checkout his Amazon Author profile.

His latest book Excel Basics to Advanced covers all the aspects of MS Excel and provides exercises for self-learning.

Similarly, his recent book, Dashboarding with Tableau, covers all the features in Tableau and includes exercises for self-learning.

He has implemented IT solutions in different domains viz. Pharmaceutical, Healthcare, Telecom, Financial and Retail.

He blogs regularly on various IT topics. Check them out in the links given below: 

Blogs

Learn Tableau

Learn All Bi

Related posts

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.