I’ve been meaning to write about the maps in Tableau for some time now as I’m really impressed with how they look, how easy they are to use and how powerful they are as a visual geographic reporting tool.
If you have geographic data, preferably with a longitude and latitude, you can display mapped data in a matter of minutes. Tableau maps allows zooming in and out, however this isn’t as user friendly as Google maps.
Depending on the Geographic Breakdown Structure (GBS) used it’s also possible to select the different levels of geography (i.e. country, state, city, etc) to display the data using the average of the longitudes and latitudes in each geography.
The example I’m using here is showing properties available for rent and/or sale on a well known website. Their GBS structure allows me to use parameters for the user to view the data at different levels of the GBS structure. For the example I’m displaying the following GBS levels:
- Country/State – the US is state level, the rest of the world at country level
- Region/State – depending on the country this can differ
- Region – this is the very bottom of the GBS, it’s the most granular level of property location data we have
It’s only a small number of steps to create the map.
Check the geographic data to create the map
The data behind the report is very simple, it contains the Latitude and Longitude of each region. This is the most granular location for each property. Also, for each region, it contains the Country, State and listings count.
This is a small sample of the data:
CountryName | StateName | Region | Lat | Long | Listings |
Alabama | Alabama Gulf Coast | Mobile | 30.4543 | -88.1314 | 9 |
Alabama | Alabama Mountains | Fort Payne | 34.32809 | -85.7176 | 9 |
Alabama | Alabama Mountains | Wilson Lake | 34.76984 | -87.4165 | 9 |
Alabama | Metropolitan Alabama | Lay Lake | 33.18677 | -86.5141 | 9 |
Alabama | Metropolitan Alabama | Logan Martin Lake | 33.49711 | -86.2244 | 9 |
Alabama | River Heritage Alabama | Lake Jordan | 32.64119 | -86.2646 | 9 |
Alabama | River Heritage Alabama | Montgomery | 32.34241 | -86.0305 | 9 |
Alabama | Alabama Gulf Coast | Josephine | 30.3224 | -87.5175 | 10 |
Alabama | Alabama Mountains | Florence | 34.82954 | -87.5736 | 10 |
Alabama | Alabama Mountains | Mentone | 34.58446 | -85.5897 | 10 |
Alabama | Alabama Mountains | Muscle Shoals | 34.79944 | -87.5701 | 15 |
Alabama | Alabama Gulf Coast | Foley | 30.34198 | -87.6621 | 19 |
Alabama | Metropolitan Alabama | Wedowee | 33.32353 | -85.5982 | 27 |
Alabama | Alabama Mountains | Weiss Lake | 34.13304 | -85.6695 | 28 |
Alabama | Alabama Mountains | Lewis Smith Lake | 34.05801 | -87.1064 | 46 |
Alabama | Metropolitan Alabama | Tuscaloosa | 33.31168 | -87.5601 | 46 |
Alabama | River Heritage Alabama | Lake Martin | 32.7671 | -85.8594 | 55 |
Alabama | Alabama Gulf Coast | Fairhope | 30.50429 | -87.9104 | 63 |
Alabama | Alabama Gulf Coast | Ono Island Orange Beach | 30.57985 | -87.42 | 63 |
Alabama | Alabama Mountains | Guntersville Lake | 34.43801 | -86.2435 | 99 |
Alabama | Alabama Gulf Coast | Dauphin Island | 30.25082 | -88.1252 | 191 |
Alabama | Alabama Gulf Coast | Fort Morgan | 30.23378 | -87.9155 | 769 |
Alabama | Alabama Gulf Coast | Orange Beach | 30.27351 | -87.5849 | 1,483 |
Alabama | Alabama Gulf Coast | Gulf Shores | 30.24537 | -87.7534 | 3,110 |
Alaska | Big Lake | Big Lake | 61.52685 | -149.869 | 9 |
Alaska | Denali | Denali | 63.22011 | -147.691 | 9 |
Load this data into Tableau and you will notice the Latitude, Longitude and Listings fields will be in the Measures section.
Building the Tableau map
To create the map, hold the ctrl key and click on the 3 fields, selecting them all.
Next click Show Me! in the toolbar. The Map chart type should highlight automatically.
Clicking OK should create the map. However, because it’s showing the Avg of the longitudes and latitudes I expect the data will appear as one large blob in the middle of the screen.
To split the blob place one of the GBS levels on the Detail shelf.
Adding the Country on the Detail shelf makes this look more like a map. Now a blue blob will appear in each country. Similarly if State is on the Detail shelf there will be a blue mark in each State.
In the example the user is able to choose which level of the GBS they want to see. This is by using a parameter, which enables the user to select the level, and a calculated field which uses the result of the selection, thereby displaying the selected GBS level. This is covered in previous post about how a user can display what they select in a report.
Once the parameter and calculated field are created, to finish put the new calculated field to the LOD shelf, replacing CountryName. Now the core of the map view are complete. All that remains is to tidy it up; the titles, tooltips, etc.
How do you grab and move the map so that it is centered, or whatever, on the screen? I’m not talking about zooming in on a particular area. I mean grabbing the map and moving it around like the way you can grab a pdf and move it with the hand. Holding down the left or right (or both!) key does not do it.
Never mind. I found the answer here – http://community.tableausoftware.com/thread/112925. So frustrating!