Shape Maps in Power BI

Philip Treacy

April 15, 2021

In this post I'm going to show you how to use Shape Maps in Power BI, which are currently a preview feature.

example shape map

Typically, Shape Maps are used to illustrate the variation of a variable across a geographic area like a country or state.

But you can also create custom shape maps for things like buildings, seating arrangements, or custom geographic regions.

I'll explain how to assign colors using color saturation, and how not to use colors, plus I'll show you a trick to plot categorical data and assign specific colors to the categories.

Watch the Video

Subscribe YouTube

 

Download PBIX Desktop File

Enter your email address below to download the sample files used in this post.

By submitting your email address you agree that we can email you our Excel newsletter.

 

Getting Started With Shape Maps

Shape Maps are a Preview Feature in Power BI Desktop and are not enabled by default.

To turn on Shape Maps, go to the File menu -> Options and settings -> Options

file options settings

Click on Preview features and check the box beside Shape map visual.

preview feature shape map

Click OK, then restart PBI Desktop.

Once restarted you should have Shape Map available in the visuals.

shape map visual icon

Adding a Shape Map

The first thing I'm going to visualize is the population distribution in mainland Australia by state and territory.

NOTE: Mainland Australia comprises six states and 3 internal territories, although the Jervis Bay territory is counted as part of the ACT for administration purposes. So in practice you'll see six states and two territories on maps. More info.

Here's my data, from 2020, sourced from WikiPedia.

sample dataset

I'm using the state/territory abbreviations as well as the ISO standard codes. I'll talk more about these in a bit.

Click on the Shape Map icon in the Visuals area to add a map. You'll see a placeholder appear on the canvas.

shape map placeholder

Add Population to the Color Saturation well and State/Territory to Location - and my map shows the USA.

usa map

What's going on?

First, notice that the map of the USA has some color applied. That's because WA is the abbreviation for both Washington state in the USA, and Western Australia.

Because the default map is displaying USA, PBI thinks the data I've given it is for the USA so it does it's best to plot that data.

However if I change Location to contain the ISO codes for the Australian states and territories PBI now knows my data is for Australia and doesn't plot it in the USA map.

using ISO code in shape map

So if you are using a map with places that have identical names or abbreviations, you must use a unique identifier for each location.

So I change the map to Australia

switch to map of australia

and everything is plotted correctly.

map of australia

I can actually remove the ISO states and just use the State/Territory (which are abbreviations) or the full State/Territory Name and I'll get the same results.

australia map state and territory names

This is of course because there aren't any states or territories with the same abbreviations or name, and because the map keys understand both the abbreviations and full state and territory names.

Map Keys

If you look here at the map keys

view map keys

You can see the unique identifiers the map recognises. You can use any of these to refer to the areas in the map, which is why I can use both full state/territory names, or their abbreviations.

map keys

Add A Table

There aren't any labels for the map so it can help to add a table. In practice the map won't generally be on its own. It'll be used in conjunction with other visuals which will give you that missing information like state/territory names.

add a table visual

To make the table more helpful I can add conditional formatting for both columns to match the map colors.

To do this, click on the table, then in the Values, click the down arrow beside State/Territory Name -> Conditional Formatting -> Background Color.

add conditional formatting to table

The settings are almost the defaults.

  • Format by : Color scale
  • Apply to : Values only
  • Based on field : Select Population here and it will display as Sum of Population (the default summarization)
  • Summarization : Sum
  • Default formatting : As zero
  • Minimum : Lowest value
  • Maximum : Highest value

conditional formatting rules for table

Repeat for the Population column.

table matches map colors

Color for Minimum and Maximum Values

If I select a state or territory from the table, like Tasmania, it's highlighted in the map - but notice that it's color has changed from the color it has when nothing is selected.

color changes when map selected

This is because I've used the default settings for the Max and Min values in the Data Colors.

default min max

I haven't specified anything for either so PBI uses the smallest and largest values currently selected (or all values if nothing's selected).

So if I select Tasmania it changes from pale blue to deep blue because with only one state selected, that state is given the color for the largest value, the deep blue.

To prevent this behaviour and force each state/territory to stay the same color regardless of selections, I can manually enter minimum and maximum values for the map colors.

specify min and max values

These values are still the minimum and maximum populations, but these numbers will now always be used to assign a color in the range given he specific max and min values, regardless of active selections in other visuals.

Now if I click Tasmania in the table, it stays the same color in the map.

map selection keeps same color

Manually Choosing Map Colors

You can choose your own map colors but choosing dissimilar colors leads to confusion - I don't know what the map is telling me now.

manual color selection

Likewise, turning Diverging colors on for this map is not helpful.

map with diverging colors

Using the Legend

Adding State/Territory to the Legend colors each one individually, but again you lose the meaning of the message here. The colors no longer indicate the population distribution.

using map legend for colors

If the purpose it to educate the viewer on the location and names (or abbreviations) of the states/territories you can use this map to do this. But if you had a lot of items in the Legend it will look very messy.

Categorical Data

OK let's look at another use for shape maps. Rather than seeing the distribution of a value like population, I want to see which political parties have been elected to which state/territory.

At the moment in Australia we only have 2 parties in power : Labor and the Liberals. Here you can see which party is in control of which state or territory.

australian elected parties

It's not obvious how to create a shape map based on text values, but it's super easy.

Start by inserting the Shape Map visual, then insert the State/Territory Name in the Location field, the Elected Party in the Legend field and the Elected Party again in the Color Saturation field. Power BI will count the Elected Party, which is fine:

categorical shape maps

You can then apply the colors you want in the Data Colors settings:

categorical shape map color coding

Where To Get Extra Maps

You may have noticed there aren't many default maps available

available map selections

Shape Maps in PBI are a type of map known as TOPO-JSON. You can search online for sites that provide them.

6 thoughts on “Shape Maps in Power BI”

  1. I have been sent some location data in the form of a .kml file which is displayed in Google Earth. How can I add that data to an existing shape map in Power BI?

    Reply
    • Hi Robert,

      I’m not familiar with the .kml file type, sorry. Shape maps can only plot county, state and country level of data. I suspect your location data is more precise than that and therefore not suitable for shape maps..

      Mynda

      Reply
      • Thank you, Mynda. That makes sense!!

        On the maps of Australia above, that Philip has been demonstrating, is it possible to also display the data values on the shape map rather than colouring as a ‘heat’ map?
        ie. add the actual populations to the various states directly on the map visual?

        Reply

Leave a Comment

Current ye@r *