Using both map layers together

As described on the Adding data to the map page, the OS Maps for Power BI visual supports two main data-driven map layers: a Marker Points layer and a Features Layer. (Additionally, there is a separate reference layer which is not linked to the Power BI data).

However in order to display data in both of these layers simultaneously, you need to carefully structure your data in a certain way. This page explains what is needed, and why.

Understanding the limitations of visuals

As with all custom Power BI visuals, the OS Maps for Power BI visual does not have any access to your Power BI data model. It only ever "sees" the fields (or summaries) that are added to the field wells on the Build Visual pane. Every time the visual is refreshed, Power BI calculates and passes the latest representation of these fields into the visual to be displayed.

Power BI will only pass a single view of data (a table, in effect) at any one time into the visual, based on what has currently been added to the field wells on the Build Visual pane. There is no facility for a visual to receive more than one separate "table" of data from Power BI.

So, in order to display two separate layers on the map, the data for each layer have to be related in some way so that Power BI is able to combine them into one table, and so that the visual can interpret which row of data should be displayed on which map layer.

To enable this to work, you need to understand the effect of applying groupings / summaries to your data fields, and you may need to create a new query that combines multiple inputs, in order to drive the visual.

Illustration

Consider a query or table representing point locations of events. The table contains a unique easting and northing for each row, and each row also contains a GSS code representing the ward in which that point falls. The first few rows might look like this:

A screenshot of a table representing point locations of events with their corresponding admin ward code
A table representing point locations of events

If we add just the easting and northing fields to the visual, the visual will receive one row of data for each point and the map displays as expected.

If instead of this we add the admin_ward_code field to the visual (into the GSS identifiers to geocode field well), the visual will receive one row of data for each unique value of admin_ward_code - not one for every row of the table - enabling it to create the map that's expected:

A screenshot of the admin ward code table for map points
Admin ward code table

However if we add both the point locations and the ward codes, the visual will receive a table as in the first example, containing duplicate ward codes. This table will be rendered correctly, showing both layers, and the visual will warn you that it has received duplicate features in the Features Layer.

The difficulty comes when we try to summarise one or more of the features. For example if we try to plot a choropleth showing a count of points within each polygon. You might add a separate "point ID" field to the Features Layer: Colour field well and choose to summarise this by Count.

However, this will not work. Because Power BI passes the easting, northing, and admin_ward_code into the visual all as part of the same data view / table, if you summarise by count the only thing it can do is count the rows for each unique combination of (easting, northing, admin_ward_code), meaning that the map will end up showing a count of 1 for each polygon.

Solution

The easiest way around this is to create a new query for feeding data to the visual. This query needs contain the columns needed for the marker points layer, and also the columns needed for the features layer. It should have two sets of the rows appended together. The first set will have all the columns required for the marker points layer populated, with the columns for the features layer set to null. The second set will have all the columns for the features layer populated, with the columns for the marker points layer set to null.

A screenshot of a table showing Postcode, Property Type, Output Areas, and Obseved value fields
This query appends two others, one containing postcodes giving information about point locations, and one containing Output Area codes giving information about polygon geographies

When using the OS Maps for Power BI Visual, or any other visual, you can gain insight into exactly what data the visual is receiving based on your current settings by selecting "Show As Table" from the "..." menu in the top right of the visual:

A screenshot of the Show as a table menu item in the context menu of the Visualizations window of the Power BI plugin
Show as a table menu next to the Visualizations pane

If your use case involves being able to filter point data but you need boundaries (polygons) to always display on the map, regardless of how the point data is filtered on the page, then see the How to add a polygon reference layer to a map page.

Data can be combined outside of Power BI or by using built-in Power BI functionality: Append queries - Power Query | Microsoft Learn

If using Power BI’s data model view to relate data sets to one another, then the following Power BI help article may help: Model view in Power BI Desktop - Power BI | Microsoft Learn.

Alternatives

If you want to display points on the map in conjunction with polygon features, but the polygons are only for reference and do not need to be linked to any other Power BI data, you can more easily do this by adding a polygon Reference Layer to the map instead (if they are based on ONS geographies), or by using the Upload Manager to upload spatial data for the polygons and then displaying them as Unmatched Features when styled on the map.

Last updated

Was this helpful?