Tableau’s “out of the box geocoding” functionality creates a wealth of opportunities for users to create beautiful maps almost instantly. This is continually one of the most “in-demand” sections for students who have attended my Tableau trainings. There are few other software applications which are this flexible and quick to build in geospatial analyses, and users are anxious to implement them.
Tableau can map fields with several different geographic roles:
Role | Description |
Area Code | US Only |
CBSA / MSA | US Only |
City | Worldwide |
Congressional District | US Only |
Country | Worldwide, includes names and characters |
County | US Only |
Latitude / Longitude | Worldwide, numeric fields only |
State / Province | Worldwide, includes abbreviations and names |
ZIP Code / Postal Code | Select Countries |
The beauty of these roles is that we do not need the latitude or longitude in our dataset. Tableau knows it for us!
The Issue
International analyses often want to map at the level of “Country,” comparing one sales figure to another around the globe. Even further, Tableau understands country codes (i.e. “US”) and names (i.e. “United States”). While this gives us a lot of flexibility, in a recent training course, one student pointed out that this could also present an issue. They had a simple challenge:
“It maps data to Africa, specifically Namibia, when all I have is Europe in my dataset.”
I thought this seemed odd, as the student was certain they only captured data for Europe. So, we started digging. I’ve recreated a dummy dataset below to investigate. The student’s map looked something like this, and sure enough, there were sales in Southern Africa
Investigating with a Crosstab
Whenever presented with a quandary like this in Tableau, its best to do some ad hoc investigation to figure out what’s going on. We opened up a new sheet and built a simple crosstab to see what was going on:
Sure enough, there wasn’t any data for Namibia in his dataset, but there was an “N/A” – a field commonly used to denote “Not Applicable.” Apparently, Tableau can also consume a “/” inside of a country code, as the code for Namibia is NA. How then should we account for this?
Tableau has a great option for renaming locations which are currently listed as NULLs. This is available by right-clicking in the map and selecting “Edit Locations.” This works great to transform a NULL into a desired country name, but we can’t transform something BACK to a NULL.
Hmm … what to do, what to do.
The Solution
The best solution I’ve found so far is to dynamically rename any Country field of “N/A” as “NULL.” That way, Tableau will not map it. The calculated field looks something like the following:
From here, we can map “Renamed Country” instead of “Country Name.” We get a map that has one NULL and only shows Europe:
Can you think of any other way you would handle an issue like this? We tackle nuances like this and many others in our Tableau training classes. You can learn more about Tableau training from InterWorks at our Tableau Training page.