Sub topic 10
Plotting geographic data on maps
This chapter assumes you can build a basic report in Power BI Desktop, that your model has related tables, and that you know how a measure aggregates values. Here you will learn when a map is the right visual and how to set one up so the locations resolve correctly.
When a map is the right choice
Use a map when the question is "where?" and the position of a place matters to the answer. If you only need to rank regions, a sorted bar chart is easier to read than a map. Large areas draw the eye whether or not their values are large, so a map can hide a small region with a big number.
| Visual | Best for | Typical field |
|---|---|---|
| Map | Points or bubbles at places | City, address, latitude and longitude |
| Filled map | Shaded areas by value | Country, state, postal code |
Prepare the geographic fields
Power BI sends location text to Bing Maps to find coordinates, so the data must be clear. Follow these steps:
- Select the column in the Data view.
- On the Column tools tab, set Data category to City, State or Province, Country/Region, Postal Code, and so on.
- Prefer unambiguous values. "Paris" can be in France or Texas, so add a Country field to the Location well, or build a combined column.
- If you have coordinates, put them in the Latitude and Longitude wells. This is faster and more precise than geocoding text.
Build a bubble map
Reuse the base measure from earlier chapters. It supplies the bubble size.
Total Sales = SUM ( Sales[SalesAmount] )Then do the following:
- Add the Map visual.
- Drag
Geography[City]to Location. - Drag
Geography[Country]to Legend only if you need colors by country, and keep the number of colors small. - Drag
[Total Sales]to Bubble size.
For areas, switch to Filled map, place Geography[State] in Location, and put [Total Sales] in Color saturation.
A filled map shades whole areas, so a sparsely populated state looks as important as a dense one. When sales depend on population, use a ratio measure, such as sales per customer, instead of the raw total.
Common problems
- Pins in the wrong country. The text was ambiguous. Add a higher-level field or use latitude and longitude.
- Blank map. The map visual may be disabled by your admin, or the data category is not set.
- Unreadable bubbles. Too many overlapping points. Filter, aggregate to a larger area, or use a table.
- Color misleads. Raw totals reflect the size of an area. Normalize with a measure.
Exercise
Your data has a Region column with values like "Springfield" for stores in several US states. Pins land in the wrong places. Give two fixes.
Show answer
Add a State field to the Location well so each Springfield resolves with its state, or use latitude and longitude columns. Setting the correct Data category helps as well.