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 – although this isn’t the most user friendly when compared to the likes of 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 US website with subsidiaries in Australia and Brazil. 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 deepest level we have as to where the property is located
A map report like this can be created in a small number of steps. The data behind the report is very simple, it contains the Latitude and Longitude of each region (the most granular location for each property) with the regions’ country/state and the count of listings in each location.
This is a small sample of the data:
|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||Muscle Shoals||34.79944||-87.5701||15|
|Alabama||Alabama Gulf Coast||Foley||30.34198||-87.6621||19|
|Alabama||Alabama Mountains||Weiss Lake||34.13304||-85.6695||28|
|Alabama||Alabama Mountains||Lewis Smith Lake||34.05801||-87.1064||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|
Once this data is loaded into Tableau the Lat, Long and Listings fields will be in the Measures section. To create the map holding down the ctrl key click on the 3 fields so they are all highlighted then click Show Me! in the toolbar. The Map chart type should be automatically selected.
To break them out one of the GBS levels needs to be in the Level Of Detail (LOD) shelf.
This will now make the map look more like a map – now a blue blob will appear in each country.
In the example I have allowed the user to choose which level of the GBS they want to see. This is done by using a parameter from which the user selects and a calculated field which uses the result of the parameter selection to return to desired GBS level. In a previous post about how a user can display what they select in a report I have given a description of how to do this.
Once the parameter and calculated field are created the next step is to put the calculated field into the LOD shelf in place of CountryName and the bones of the report are now complete, all that remains to do is to tidy up the titles, tooltips, etc.