Get Started Mapping with Tableau
This tutorial walks you through some of the most common tasks you might perform when creating maps in Tableau.
You'll learn how to connect to and join geographic data; format that data in Tableau; create location hierarchies; build and present a basic map view; and apply key mapping features along the way.
If you're new to building maps in Tableau, this a great place to start.
Step 1: Connect to your geographic data
Geographic data comes in many shapes and formats. When you open Tableau Desktop, the start page shows you the connectors available in the left Connect pane. These are how you will connect to your data.
You can work with geographic data by connecting to spatial files, or you can connect to location data stored in spreadsheets, text files or on a server.
Spatial files, such as a shapefile or geoJSON file, contain actual geometries (points, lines or polygons), whereas text files or spreadsheets contain point locations in latitude and longitude coordinates, or named locations that, when brought into Tableau, connect to the Tableau geocoding (stored geometries that your data references).
For a complete list of connections Tableau supports, see the list of Data Connections(Link opens in a new window) on the Tableau website.
For this tutorial, you are going to connect to an Excel file that comes with Tableau Desktop. It contains location names that Tableau can geocode. When you build a map view, the location names reference the geometries stored in the Tableau Map Service based on the geographic role you assign to the field. You'll learn more about geographic roles later in this tutorial.
Open Tableau Desktop.
In the Connect pane, click Excel.
Navigate to Documents > My Tableau Repository > Data Sources, and then open the Sample - Superstore.xls file.
Once you connect to the data source, your screen will look like this:
This is called the Data Source page, and it is where you can prepare your location data for use in Tableau.
Some of the tasks you can perform on the Data Source page include the following, but you don't have to do all these things to create a map view:
- Adding additional connections and joining your data
- Adding multiple sheets to your data source
- Assigning or changing geographic roles to your fields
- Changing the data type of your columns (from numbers to strings, for example)
- Renaming columns
- Splitting columns, such as splitting a full address into multiple columns for street, city, state and postcode
For more information about the Data Source page and some of the tasks you can perform while on it, see the topics in the Set Up Data Sources(Link opens in a new window) section.
Step 2: Join your data
Your data is often held in multiple data sources or sheets. As long as those data sources or sheets have a column in common, you can join them in Tableau. Joining is a method for combining the related data on those common fields. The result of combining data using a join is a virtual table that is typically extended horizontally by adding columns of data.
Joining is often necessary with geographic data, particularly spatial data. For example, you can join a KML file that contains custom geographies for school districts in Oregon, U.S. with an Excel spreadsheet that contains demographic information about those school districts.
For this example, you will join two sheets in the Sample-Superstore data source.
On the left side of the Data Source page, under Sheets, double-click Orders.
Under Sheets, double-click People.
Tableau creates an inner-join between the two spreadsheets, using the Region column from both spreadsheets as the joining field. Now there is a sales person assigned to every location in your data source, as well as to regions.
To edit this join, click the join icon (the two circles). You can edit the join in the Join dialog box that opens. For more information about joining data in Tableau, see Join Your Data(Link opens in a new window).
Step 3: Format your geographic data in Tableau
After you set up your data source, you might need to prepare your geographic data for use in Tableau. Not all of these procedures will always be necessary to create a map view, but it's important information to know when it comes to preparing geographic data for use in Tableau.
Depending on the type of map you want to create, you must assign certain data types, data roles and geographic roles to your fields (or columns).
For example, in most cases, your latitude and longitude fields should have a data type of number (decimal), a data role of measure, and be assigned the Latitude and Longitude geographic roles. All other geographic fields should have a data type of string, a data role of dimension and be assigned the appropriate geographic roles.
Note: If you are connecting to a spatial file, a Geometry field is created. It should have a data role of measure.
This step demonstrates how to format your geographic data to meet this criteria.
Change the data type of a column
When you first connect to geographic data, Tableau assigns data types to all of your columns. These data types include Number (decimal), Number (whole), Date and Time, Date, String and Boolean. Sometimes Tableau does not get these data types right, and you must edit them. For example, Tableau might assign a Postcode column a data type of Number (whole). To create map views, your Postcode data must have a data type of String.
To change the data type of a column:
On the Data Source page, click the data type icon (the globe) for Postcode and select String.
For more information about data types, see Data Types(Link opens in a new window).
Assign geographic roles to your geographic data
In Tableau, a geographic role associates each value in a field with a latitude and longitude value. When you assign the correct geographic role to a field, Tableau assigns latitude and longitude values to each location in that field by finding a match that is already built in to the installed geocoding database. This is how Tableau knows where to plot your locations on the map.
When you assign a geographic role to a field, such as State, Tableau creates a Latitude (generated) field and a Longitude (generated) field.
Geographic roles are sometimes automatically assigned to your data, such as in this example. You can tell a geographic role has been assigned to your data because the column includes a globe icon.
If a geographic role is not automatically assigned, you can manually assign one to your field. You don't need to do so for this example, but it's important to know how so you can do it for your own data.
To assign or edit a geographic role:
On the Data Source page, click the globe icon.
Select Geographic Role, and then select a role that best matches your data.
For example, in this case, the Country column does not have a geographic role assigned to it, so the Country/Region geographic role is assigned.
Note: If you have difficulties assigning geographic roles to your data, or have data that is not built in to the Tableau map server, there are a few things you can do to get that data into Tableau. See Assign Geographic Roles(Link opens in a new window).
Change from dimensions to measures
When you connect to geographic data, Tableau also assigns data roles to all of your columns. A column can be a dimension or measure. In most cases, your latitude and longitude columns should be measures. For special cases, such as if you want to plot every location in your data source on a map without the ability to drill up or down a level of detail (such as from City to State), they can be dimensions. A great example of this is a point distribution(Link opens in a new window) map.
The rest of your geographic data should be dimensions.
You don't need to change the data role of a column for this example, but it's important to know how so you can do it for your own data. Feel free to practise here. You can always undo any changes you make.
To change the data role of a column:
On the Data Source page, click Sheet 1.
Your workspace updates to look like this:
This is called a worksheet, and it is where you will build your map. On the left-side of the screen is the Data pane. All of the columns in your data source are listed as fields in this pane. For example, Country and State. These fields contain all the raw data in your columns. Note that Tableau has generated a Latitude and Longitude field (Latitude (generated) and Longitude (generated)). This is because you assigned geographic roles to your data.
The fields in the data pane are divided into measures and dimensions. The fields placed in the Dimensions section of the Data pane are often categorical data, such as Date and Customer ID, while the fields placed in the Measures section of the Data pane are often quantitative data, such as Sales and Quantity.
In the Data pane, under Dimensions, select a field, such as Row ID, and drag it down to the Measures section.
The field is added to the Measures section and changes from blue to green. You just converted a Dimension to a Measure. To convert a field from a measure to a dimension, drag the field from the Measures section up to the Dimensions section.
For more information, see Dimensions and Measures, Blue and Green(Link opens in a new window).
Step 4: Create a geographic hierarchy
Now that you are in the worksheet space, you can create geographic hierarchies. This is not required to create a map view, but creating a geographic hierarchy will allow you to quickly drill into the levels of geographic detail your data contains, in the order you specify.
To create a geographic hierarchy:
- In the Data pane, right-click the geographic field, Country, and then select Hierarchy > Create Hierarchy.
In the Create Hierarchy dialog box that opens, give the hierarchy a name, such as Mapping Items, and then click OK.
At the bottom of the Dimensions section, the Mapping Items hierarchy is created with the Country field.
In the Data pane, drag the State field to the hierarchy and place it below the Country field.
Repeat step 3 for the City and Postcode fields.
When you are finished, your hierarchy should be in the following order:
- Country
- State
- City
- Postcode
Step 5: Build a basic map
Now that you have connected to and joined your data, formatted your data and built a geographic hierarchy, you are now ready to start building your map. You will start by building a basic map view.
In the Data pane, double-click Country.
The Country field is added to Detail on the Marks card, and Latitude (generated) and Longitude (generated) are added to the Columns and Rows shelves. A map view with one data point is created. Since a geographic role is assigned to Country, Tableau creates a map view. If you double-click any other field, such as a dimension or measure, Tableau adds that field to the Rows or Columns shelf, or the Marks card, depending on what you already have in the view. Geographic fields are always placed on Detail on the Marks card, however.
Since this data source only contains one country, (United Kingdom), that is the only data point shown. You will need to add more levels of detail to see additional data points. Since you created a geographic hierarchy, this is easy.
On the Marks card, click the + icon on the Country field.
The State field is added to Detail on the Marks card and the map updates to include a data point for every state in the data source.
If you did not create a hierarchy, the + icon on the Country field will not be available. In this case, to add State as another level of detail, manually drag State from the Data pane to Detail on the Marks card.
Congratulations! You now have a basic map view that you can customise and build upon in the next steps.
Step 6: Change from points to polygons
The default map type in Tableau is often a point map. When you have geographic roles assigned to your geographic data, however, it's easy to change those data points to polygons.
Note: Filled maps are not available for cities or airports.
On the Marks card, click the Mark Type drop-down and select Filled Map.
The map updates to a polygon map.
Step 7: Add visual detail
You can add measures and dimensions to the Marks card to add visual detail to your view. In this example, you will add colour and labels to the view.
Add colour
From Measures, drag Sales to Colour on the Marks card.
Each state is coloured by sum of sales. Since Sales is a measure, a qualitative colour palette is used. If you place a dimension on colour, then a categorical colour palette is used.
Add labels
From Measures, drag Sales to Label on the Marks card.
Each state is labelled with sum of sales. The numbers need a little bit of formatting, however.
In the Data pane, right-click Sales and select Default Properties > Number Format.
In the Default Number Format dialog box that opens, select Number (Custom), and then do the following:
For Decimal Places, enter 0.
For Units, select Thousands (K).
Click OK.
The labels and the colour legend update with the specified format.
Step 8: Customise your background map
The background map is everything behind your marks (borders, oceans, location names, etc.) You can customise the style of this background map, as well as add map layers and data layers. In addition to customising the background maps, you can also connect to your own WMS server or Mapbox map. For more information, see Use Web Map Service (WMS) Servers(Link opens in a new window) and Use Mapbox Maps(Link opens in a new window).
To customise your background map:
Select Map > Map Layers.
The Map Layers pane appears on the left side of the workspace. This is where all background map customisation happens.
In the Map Layers pane, click the Style drop-down and select Normal.
The background map updates to look like this:
In the Map Layers pane, under Map Layers, select Coastlines, and then clear Country/Region Borders, Country/Region Names, State/Province Borders, and State/Province Names.
At the top of the Map Layers pane, click the X to return to the Data pane.
The background map is now simplified to draw attention to your data.
Step 9: Create custom territories
As you build your map view, you might want to group existing locations together to create your own territories or regions, such as sales territories for your organisation.
In the Data pane, right-click State and select Create > Group.
In the Create Group dialog box that opens, select California, Oregon and Washington , and then click Group. Each group you create represents a territory.
Note: To multi-select, hold down Ctrl (Command on Mac) as your select states.
Right-click the new group you just created and select Rename.
Rename the group, West Coast.
For the next territory, select Alabama, Florida, Georgia, Louisiana, Mississippi, South Carolina and Texas, and then click Group.
Rename this group, South.
For the third territory, select Connecticut, Delaware, District of Columbia, Main, Maryland, Massachusetts, New Hampshire, New Jersey, New York, Pennsylvania, Rhode Island, Vermont and, finally, West Virginia and then click Group.
Rename this group, East Coast.
Select Include Other to group the remaining states.
Rename the Other group, Central.
Click OK.
A State (group) field appears in the Data pane beneath your other mapping items.
From the Data pane, drag State (group) to Colour on the Marks card.
The view updates to look like this:
Notice that each group has a different colour.
On the Marks card, click the Colour icon and select Edit Colours.
In the Edit Colours dialog box that appears, select Assign Palette, and then click OK.
The marks update with new colours.
From Measures, drag Sales to Tooltip on the Marks card.
When you hover over a state, a tooltip appears with the sales for that state, among other information. You'll learn how to edit this tooltip later.
On the Marks card, click the minus (-) icon on the Country field to remove State from the level of detail.
If you did not create a hierarchy, you can drag State from the view to remove it. You can remove any field by dragging it from the view.
The states no longer appear on the map. Notice how the sum of sales has updated for the labels and in the tooltip? This is because custom territories aggregate at the level of the group, rather than separately for each location within the group. So the sum of sales your are seeing in the West Coast group, for example, are the total sales for California, Oregon and Washington combined.
Step 10: Create a dual axis map
So far you have created two map views: one that shows the sales per state, and one that shows the sales per region. Could you layer these maps on top of one another? Yes! In Tableau, you can create a map with two layers of marks. This is called a dual axis map in Tableau, and is often used to layer points over polygons. In this example, you will layer two polygons maps.
To create a dual axis map:
From the Data pane, drag Longitude (generated) to the Columns shelf and place it to the right of the first Longitude field.
The view updates with two identical maps.
There are now three tabs on the Marks card: one for each map view, and one for both views (All). You can use these to control the visual detail of the map views. The top Longitude tab corresponds to the map on the left of the view, and the bottom Longitude tab corresponds to the map on the right of the view.
On the Marks card, select the top Longitude (generated) tab.
From Measures, drag Sales to Colouron the top Longitude (generated) Marks card.
The map on the left updates.
On the top Longitude (generated) Marks card, click the + icon on the Country field to drill back down to the State level of detail.
On the Marks card, click Colour, and then select Edit Colours.
In the Edit Colours dialog box that opens, click the Palette drop-down, select Grey, and then click OK.
At this point, your maps look like this:
On the Columns shelf, right-click the Longitude (generated) field on the right and select Dual Axis.
On the Marks card, select the bottom Longitude (generated) tab.
On the bottom Longitude (generated) Marks card, drag both SUM(Sales) fields from the view to remove them.
The labels for each map no longer overlap.
On the bottom Longitude (generated) Marks card, click Colour, and then, for Opacity, enter 50%.
This is a crucial step if you want to be able to see the map on the bottom layer.
The map view updates to look like this:
You can now see how each state performed within each group.
On the bottom Longitude (generated) Marks card, click Tooltip.
An Edit Tooltip dialog box opens.
Copy the following text and paste it into the Edit Tooltip dialog box, and then click OK:
Total <State (group)> region sales: <SUM(Sales)>
The tooltip looks similar to this:
Congrats! You've created a dual axis map! There's only one thing left to do.
For more information about dual axis maps, see Dual Axis Mapping - Many Ways(Link opens in a new window) on the Tableau Community.
Step 11: Customise how others can interact with your map
Now that you have created your map view, you can customise how people will interact with it. For example, you might now want anyone to be able to zoom in or out of your map, or pan. Or perhaps you want to display a map scale? You can customise these two options and more in the Map Options dialog box.
To customise how others can interact with your map:
Select Map > Map Options.
In the Map Options dialog box that appears, do the following:
Select Show Map Scale.
Clear Show Map Search.
Clear Show View Toolbar.
A scale appears in the bottom-right corner of the map, and the map search icon and the toolbar in the top left corner of the map disappear. You can still pan and zoom using keyboard shortcuts. For more information, see Zoom and Pan Views and Select Marks(Link opens in a new window).
And that's a wrap! Your map view is now ready to be presented or combined with another view in a dashboard. For more information about dashboards, see Create a Dashboard(Link opens in a new window).
Want to check your work? Download the example workbook(Link opens in a new window) from Tableau Public.
What's Next?
Learn some mapping visualisation basics.(Link opens in a new window)
Looking for more advanced content? See the mapping series on the Tableau Community(Link opens in a new window).
Explore other Help content(Link opens in a new window) about mapping.
Got a specific question or problem? Check out the Mapping Forum(Link opens in a new window) on the Tableau Community or search the Knowledge Base(Link opens in a new window).