Makepoint and Makeline functions in Tableau: easy explanation and tutorial!

by Nhung Le

For today’s dashboard we have this dataset showing number of people moving from Hamburg to other states in Germany and the other way round. The dataset is here to be found.

As a part of the requirement to build something that you have never done before, I wanted to build this:

And here is how.

But before we start to build this together, I think it is helpful to understand the logic behind it. Now for each line we have Starting Point (Hamburg) and End Point (other 15 States for 15 lines). We have to have spatial formation for everything, like the table below. From Latitude From and Longitude From we can create a spatial point of the starting point and same for the destination. Afterward, we can build a line based on the spatial information of these two points.

Let's start!

1. Figure out the Latitude and Longitude for the destination states.

There are several ways to find it out, and there are also websites with give you this information. But ff you already have destination states in the dataset, put it in the map and export the Latitude and Longitude from Tableau. This blogpost show you how.

2. Figure out the Latitude and Longitude of the starting point.

Here all the stating point is Hamburg, so I simply:

- Create a calculated field containing string “Hamburg”

- Change Geographic Role to State/Province.

- Put on the map in Tableau and export the Latitude and Longitude similar to step 1.

3. Joint them to the main Dataset

4. MAKEPOINT for the starting point and the destination

Create a spatial point for each using MAKEPOINT([Latitude],[Longitude]).

Example:

START=MAKEPOINT([Latitude From],[Longitude From])

DESTINATION([Latitude To],[Longitude To]).

5. MAKELINE by connecting the spatial points.

LINE=MAKELINE([START],[DESTINATION])

6. Double click on the LINE field, it appears in the map!

The rest is optional, but you can have a look to make the map look nicer.

7. To show the point in the end of the line, drag the DESTINATION to Mark Layers.

8. To show only Germany in the background:

- Created a calculated field only for Germany

- Change its Geographical Role to Country/Region

- Drag it to Mark Layers. In the Mark Card, change to Map. No you can clean the background and remove other things!