Country Map Tutorial

While I was trying to place my data on a map using Metabase I couldn’t find enough documentation to do so.
It seems that in order to use the Country map presentation style and I guess the US States map, you will need to do the following.

First you have to return the country code in an ISO 3166-1 Alpha 2 code format. If your column does not have the data in that format, you will need to use CASE or other relevant sql function based on your database. Below there is a query to help you understand how to use CASE and return data on a map from a MySQL database.

SELECT  
	CASE Country
		WHEN 'China' then 'CN'
		WHEN 'France' then 'FR'
		WHEN 'Germany' then 'DE'
		WHEN 'Mexico' then 'MX'
		WHEN 'Malaysia' then 'MY'
		WHEN 'UK' then 'GB'
		WHEN 'USA' then 'US'
	END as Country , COUNT(ID) as Num
FROM SALES
WHERE Country !=''
group by Country
2 Likes

You can find the csv file of mappings here (replaced some names with their common name as mentioned in the Wikipedia page, e.g. Korea, Republic of is changed to South Korea).

1 Like