Tableau Maps are very useful to visualize the geographical data. In this article we will show you, How to Create a Map in Tableau with example. For this we are going to write the Custom SQL Query against the SQL Server Data Source. I suggest you to refer Connecting Tableau to SQL Server article to understand the configurations. The custom SQL query that we are going to use for this report is:
-- SQL Query to create a Map in Tableau
FROM DimProductSubcategory AS ProdSubCat
DimProduct AS Prod ON ProdSubCat.ProductSubcategoryKey = Prod.ProductSubcategoryKey
DimProductCategory AS ProdCat ON ProdSubCat.ProductCategoryKey = ProdCat.ProductCategoryKey
FactInternetSales AS Fact ON Prod.ProductKey = Fact.ProductKey
DimCustomer AS Cust ON Fact.CustomerKey = Cust.CustomerKey
DimGeography AS Geo ON Cust.GeographyKey = Geo.GeographyKey
First approach to Create a Map in Tableau
Double-click on any Geographic filed such as: City, Postcode, Country, or State will automatically create a Map in Tableau. In this example, we will double-click on the State Province Name dimension
From the below screenshot you can see that, Tableau had added the Latitude value to Row shelf, Longitude value to Column shelf, and State province Name to Details field present in Marks Shelf.
Second approach to Create a Map in Tableau
Drag and drop any Geographic filed such as: City, Country, Postcode, or State on the Details field will automatically create a Map in Tableau. In this example, we will drag the State Province Name dimension to Details field present in Marks Shelf
Now you can see the auto generated map.
You can also add the geographical hierarchy aswell. From the below screenshot you can see that, we have added the State province hierarchy (province Name, City) to details shelf.
Third approach to Create a Map in Tableau
Drag and drop any Geographic filed to Column, or Row shelf and selecting the Map from Show Me window will automatically create a Map in Tableau. In this example, we will drag the State Province Name dimension to Columns Shelf and selecting the Map present in Show Me Shelf
That will automatically create a Map
Let us add Sales Amount Measure to Colors field present in Marks Shelf. This will add color to each state based on the Amount of Sales occurred.
Thank You for Visiting Our Blog