Introduction to MAPs

## **Introduction**

*Maps are a visual representation of information about the world.* They demonstrate the size and shape of countries, the locations of landmarks, and the distances between them to visualize the world.

Whether it is deciding where to put another fast-food franchise or tracking population growth, geographic and location data are often critical to make informed business or policy decisions. Power BI offers several methods of visualizing geographic and location data on maps that make them easier to comprehend.

Bing Maps and Power BI work together to offer default map coordinates. It makes use of the Bing Maps Geocoding Engine, which sends geographical variables such as location, latitude, and longitude to Bing for geocoding processing and plotting on the map. In short, the Bing Engine converts the given information into geographic coordinates to do geospatial analysis. Visualizations based on maps are simple to make and provide a comprehensive perspective of spatial and category data.

## Types of Maps in Power BI

There are four types of maps Power BI offers:

• **Basic Maps** - Basic maps allow for the plotting of both categorical and quantitative features of a data set on a map.

• **Filled (Choropleth) Maps** - Filled maps use shading or colors on bounded geographic areas to show differences in categorical or quantitative variables across different regions.

• **Shape Maps** - Shape maps are used to compare custom regions on maps using shading and color and are unable to show precise geographical coordinates. Shape maps can also be used to create custom maps.

• **ArcGIS Maps** - ArcGIS (Geographical Information Systems) is a spatial analysis software developed by **ESRI** that can be used to compile geographic and location data on layered maps.

In this tutorial, we’ll discuss about creating and formatting Basic and Filled Maps.

## **Dataset Preparation for Maps**

### **Step 1: Load Your Data**

You need to choose your required data source or your required data file to work on with Power BI Mapping. Follow the below steps to load an CSV file:

• Open your Power BI platform and navigate to *Home → Get Data → Text/CSV* as shown below. You can choose as per your data file type.

• From the pop-up window, choose your desired file source and click on Open. You can download the data file here: **Costco-Stores-USA.**

• Now, click on the *Load* option to upload your data. And wait for the data to load in power BI.

### **Step 2: Verify the data set is properly geo-coded**

The basic requirement to create any maps in power BI is that the data set contains data about either longitude/latitude coordinates or some combination of address, city, state, country, or continent.

When you are using any dataset like above, the first thing to check after the data is loaded, is to make sure that your location data is **correctly geo-coded**. What this means is that you should check if your data are categorized. An easy way to check it is on the fields pane of your report’s builder. A location data is correctly categorized when you see a globe icon beside it. If not, you’ll have to change and set the data categorizations.

**To set a data category follow these steps**

1. In **Report** View or **Data** View, in the **Fields** list, select the field you want to be sorted by a different categorization.

2. On the ribbon, in the Properties area of the **Column tools** tab, select the drop-down arrow next to **Data Category**. This list shows the data categories you can choose for your column. Some selections might be disabled if they won't work with the current data type of your column. For example, if a column is a date or time data type, Power BI won't let you choose geographic data categories.

3. Select the category you want. This will categorize the column and a globe icon will appear beside the column name in the Fields list. Do this to all the location related columns.

Your Data is now ready to create maps!!

## **Creating and Formatting Maps**

### **Power BI (BASIC) MAP**

This type of map is best for **basic display**. This map has been merged by Power BI with Bing Maps to offer default map coordinates (also known as geo-coding) so that Power BI Maps can be created easily and accurately. There is not much customization you can do as this is only good for common uses. However, there are certain things you can do to make it look better and fit your purposes like changing the map style and turning it into a heat map.

**Pros:**

* Easy to use
* Fully supported by the Microsoft Power BI team
* Perfect for basic and common uses
* Small points can also be easily and realistically represented.

**Cons:**

* Rare geocoding issues giving you inaccurate locations
* No support for custom geographic formats like GeoJson, ESRI Shapefiles, and others

**Steps to Create & Customize a Basic Map**

To create a basic map, click the map icon on the visualizations pane and drag the type of field you would like to use to create the map.

Let us use the stores’ **‘City’** location and drag it to the **‘Location’** bucket:

The basic map is now created!! Each bubbles represent one city from the data. If you like, you could add another field on the ‘Bubble Size’ bucket that would show its relevance to the location.

For example, adding **‘Count of ID’** will show you the number of stores in that city. We just need to simply drag the **‘Count of ID’** field to the **‘Bubble Size’** bucket:

One issue that we may sometimes face using only city name to map data is that there could be multiple cities in the world with same name. So, it’s a better practice to add or **use latitude and longitude** values to your dataset. This would clearly erase any ambiguity in your location and the created map will be error free. To use this option, simple drag and drop latitude and longitude columns from Fields panel into Latitude and Longitude buckets of the visualizations panel.

**To Format the map**, we can use ‘Format your visual’ section in the Visualizations panel. There are lots of formatting options on a basic map. These options are divided into two categories: Visual and General.

• The Visual section enables the user to set how the map looks. This gives options to change the style of the map, change controls, set legend options, change bubble size, and color and set category labels.

• The General section is more about formatting the general properties of the map like the Size, Title, Effects, Header, and Tooltips etc.

After changing the bubble sizes, bubble colors, Map style, zoom buttons, and labeling the map title from the Format window etc., our map looks like this:

**Heat Map:** A Power BI Heatmap is a type of visualization that demonstrates the density of data on a map. Basic map gives you the option to create a heatmap very easily.

If you would like to turn the **‘Heat map’** on, just click on the button to toggle it from **‘Off’** to **‘On’**. You may change colors or options accordingly to create desired output. Turning on the heat map would also affect the available formatting options. Try each of the options and see how it affects the map.

### **Filled Map**

A filled, or choropleth, map uses shading or tinting or patterns to display how a value differs in proportion across a geography or region. You can quickly display relative differences with shading that ranges from light (less frequent/lower) to dark (more frequent/more).

**Pros:**

* Easy to use, has Power BI’s full support.
* Also has map styles available
* Flexible map, highly customizable

**Cons:**

* Rare geocoding issues giving you inaccurate locations
* No support for custom geographic formats like GeoJson, ESRI Shapefiles, and others.

**Steps to Create & Customize a Filled Map**

To create a filled map, click the **‘filled map’** icon on the visualizations pane and drag the type of field you would like to use to create the map. The ‘Filled Map’ icon is just beside the ‘Map’ icon in the visualizations panel.

This time, we’ll not be using City or latitude/longitude data. Rather we’ll use ‘State’ which is a more fitting location data for this map.

After clicking the **icon**, an empty filled map will appear on the canvas. To fill it with data, drag the **‘State'** field to the **‘Location’** bucket. Filled maps require a field in the Location bucket; even if latitude and longitude are provided. Whatever data is in the **Location, Latitude,** or Longitude bucket is sent to Bing.

• The filled map is created and looks a bit similar to the basic map except for the **filled states that has Costco stores marked in blue color**.

• At the first look we can easily distinguish that **Maine, Rhode Island, West Virginia and Wyoming** does not have any Costco stores and the map is blank for this state.

**To Format this map**, we can use ‘Format your visual’ section in the Visualizations panel similar to basic map. There are also lots of formatting options on a filled map. These options are divided into two categories: Visual and General. While the General options are similar to both basic and filled maps, the Visual options are less in case of a filled map. The heat map option is also not included for a filled map.

We can use the conditional formatting option from Fill Color section to manually set the fill colors and what field should the fill color be based on.

After customizing the Fill Color, Map style, zoom buttons, and labeling the map title, tooltip from the Format window etc., our filled map looks like this:

## **Tips and Tricks for Better Power BI Mapping Visualizations**

**Power BI** leverages **Bing Maps** to offer default map coordinates, also known as geo-coding, so you can generate maps, as mentioned in the previous sections. There are a few actions you can do to improve the chances of accurate geo-coding:

* To ensure Bing correctly encodes your data, try **categorizing your geographic** **fields** using the Data Category option.
* Since locations can be ambiguous at times, it’s a good idea to **include more than one location column** to accurately identify your intended location.
* Power BI gets the latitude and longitude coordinates based on a set of address values for any country using Bing’s unstructured URL template service. **Add latitude & longitude columns** and label them correctly if your data lacks enough location data.
* Make sure **each field only has one category for location.** Your location field, for example, should be New York, not New York, US.

## **Conclusion**

In summary, this guide demonstrated what Power BI Mapping is and the features of Power BI Maps.

We looked at the two different Power BI maps: basic and filled. You may learn more about the custom maps here [link to Dr. White's custom map wiki page]. We also learned a variety of tips and tricks for using Power BI Maps effectively.

If you want to learn more about the power BI application, please refer to the power **BI documentation.**

## **References and Links**

We used below sources to learn power BI tool and create this tutorial:

* **Microsoft Power BI**
* **Maps Documentation from Microsoft**

## **Disclaimer**

This tutorial is made in Oct,2022 based on Microsoft Power BI Desktop application Version: 2.109.1021.0 64-bit (September 2022).