Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
RMDNA
Solution Sage
Solution Sage

Shape Map - unique map keys

Hi all,

 

I'm using a Shape Map visual using a custom TopoJSON for US counties (us-albers-counties via here). I have the correct format for the map keys. However, when I add county to the location field, it displays all counties with that name (e.g. all Douglas counties across the US), regardless of whether they're in my dataset or not. I've tried creating a field of a County and State combo (in various formats), but adding them to the location field blanks out the map.

 

counties.PNG

 

I've attached an excel of my data. Can anyone successfully get a map working with data at the unique state/county level?

 

1 ACCEPTED SOLUTION

Hi,
I realise this is a late response and hopefully you have it sorted now but if you don't or someone else reads the thread, this might help.
Whatever field you pull into 'Location' for the shape map is the one that Powerbi uses to link to the map. I don't know how it chooses which field in the shape map to join to but there must be something clever going on. It probably has an algorithm that makes a best guess on data type and/or field name.
Obviously in this case 'county' is not unique in the shape map and so multiple counties get selected across the USA.

I tried with the supplied data set and pbi file. I added a new column combining state_fips and county_fips and padded the data where necessary to match the template XXYYY where XX is state fips e.g 05, 11 and YYY is the county fips e.g. 001, 012, 107.
We know that the us-albers-counties map has fips code in this format and that it is unique. I then pulled the new column into the 'Location' field of the shape map. This was only partially succesful. I added a slicer for State for testing and saw that not all the states were displaying appropriately.
I found that this is because of an issue with the us-albers-counties map provided. Some of the fips codes are strings and some are numbers.  So Powerbi can't make the link.

You can solve this by either getting a different USA county topojson map with the fips code in a consistent format OR as I did, edit the map in QGIS to make fips a string , export it as Geojson, convert to topojson and add it in to powerbi.  Make sure that the fips column you added earlier in powerbi is also a string.  This works.

As an aside, the 'view map keys' feature for shape maps isn't working in my desktop powerbi.  The window appears then it shrinks horizontally to about 1cm width.  Probably a bug.

 

Doug

View solution in original post

18 REPLIES 18
v-frfei-msft
Community Support
Community Support

Hi @RMDNA,

 

I made a test using the desktop of  version 2.60.5169.3201 64-bit (July 2018). And I created a same visual as yours. As your said “it displays all counties with that name (e.g. all Douglas counties across the US)”, did you mean that the grey ones should not be displayed any county name here? Actually it is not an issue, that is normal for the shape map here.

 

1.png

For more details, please check the pbix as attached.

 

https://www.dropbox.com/s/ktsykfhe9tfmdtd/Shape%20Map%20-%20unique%20map%20keys2.pbix?dl=0

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Hi @v-frfei-msft,

 

My map dataset contains a subset of US states and their counties, so I'm looking for a view of all counties within only those states, regardless if the county names exists elsewhere in the US.

 

Below is a standard map visual showing exactly what I'm looking for, which I'm trying to recreate as a shape map:

 

Intent.PNG

Bump - if there's no concrete answer to this, I'll need to attempt the same thing in MapBox.

Hi,
I realise this is a late response and hopefully you have it sorted now but if you don't or someone else reads the thread, this might help.
Whatever field you pull into 'Location' for the shape map is the one that Powerbi uses to link to the map. I don't know how it chooses which field in the shape map to join to but there must be something clever going on. It probably has an algorithm that makes a best guess on data type and/or field name.
Obviously in this case 'county' is not unique in the shape map and so multiple counties get selected across the USA.

I tried with the supplied data set and pbi file. I added a new column combining state_fips and county_fips and padded the data where necessary to match the template XXYYY where XX is state fips e.g 05, 11 and YYY is the county fips e.g. 001, 012, 107.
We know that the us-albers-counties map has fips code in this format and that it is unique. I then pulled the new column into the 'Location' field of the shape map. This was only partially succesful. I added a slicer for State for testing and saw that not all the states were displaying appropriately.
I found that this is because of an issue with the us-albers-counties map provided. Some of the fips codes are strings and some are numbers.  So Powerbi can't make the link.

You can solve this by either getting a different USA county topojson map with the fips code in a consistent format OR as I did, edit the map in QGIS to make fips a string , export it as Geojson, convert to topojson and add it in to powerbi.  Make sure that the fips column you added earlier in powerbi is also a string.  This works.

As an aside, the 'view map keys' feature for shape maps isn't working in my desktop powerbi.  The window appears then it shrinks horizontally to about 1cm width.  Probably a bug.

 

Doug

Does anyone have a copy of the updated .JSON file with the corrected strings?  I am really struggling trying to do this on my own.

It's attached to one of my posts further up.  Can it still be accessed?

 

 

Has anyone had an issue with the FIPS with leading zeros not show up or vise versa?  I am not sure if its a formatting issue - text or whole number?  Depending on which one I use, it flip flops which FIPS show.  I feel like I am missing something very simple.

Pic below is with FIPS as Whole Number

FIPS as WHOLE NUMBER.png

Pic below is with FIPS as Text

FIPS as TEXT.png

Hi DanielleDare

Have you solved the issue, as i am facing the similar issue as well. Could you please help me out 

Please try this version of the json shape map (usa fips json).   Please note, in powerbi terms this is quite a large file (1.2 MB) so it will slow the pbix down and make it quite chunky.

I've removed the one from further up the postings.

The fips code from the data you use should be a text field comprised of State and County codes. e.g. 42089 for Monroe County, Pennsylvania.

It should be pulled in to the Location field well. Color Saturation should be the numerical field you want. Anything else can be in the tooltips field well.

 

@HotChilli

 

I'm having a similar issue as OP and the issue is replicating in the PBIX file you attached.  

 

The values for non-unique counties across different states are replicated in the tooltip for Index and I'm also assuming the color saturation.  A great example in your PBIX is Lincoln county.  The tooltip will show the Index and State for Lincoln in Tennessee.

 

I am hoping to get unique saturation and values for non-unique counties. 

@markjohnson952 

I'll need the pbix if you want me to investigate

I did your method of combining the state fips and county fips into a column and use that in the Location field.  This solved it!

Hi @HotChilli 

 

I have confidential information in my PBIX but the issue is replicated in the PBIX you provided up thread.

Hi @HotChilli,

 

I never did get it figured out, so this sounds promising! Could you share your edited topoJSON and sample PBIX? I'd love to give it a try.

 sample pbix

 

The CountyFips query is from your supplied data.  The other data is from the U.S. census (i was just using it to test the shape map).

 

I hope that helps.

 

Doug

Has anyone been able to get the 5 digit State/County FIPS codes to work on either a filled or shape (ideally) map?

I pulled the 5 digit codes from https://www.nrcs.usda.gov/wps/portal/nrcs/detail/national/home/?cid=nrcs143_013697

When I imported they defaulted to numbers but I updated the field to string.

Setting the FIPS code field as location or place each result in about 1-3% of the map being filled in.

Does anyone have any advice?

 

@HotChilli 

@RMDNA 

@geoffgarcia  You have everything you need in this thread (apart from your own data).  You need a shape map with consistent format FIPS codes (attached to one of my posts).

Don't set FIPS codes as Location or Place. The shape map doesn't care about things like that.

There is a sample pbix attached above that shows how it works.

.. and they fixed the 'View map keys' bug that I was referring to, so you can use that feature too.

@HotChilli Do you have a JSON file similar to your mapping of the entirety of US counties, but by state. For example, I am looking for the same dataset, but I only want Alabama (or any other singular state) counties to be in the JSON file.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.