Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi,
I am aware how the maps are built using shape maps but my question here is -
For example: I use a Shapefile to create maps and I have converted that Shapefile to TopoJSON file using mapshaper.org, Is it possible to use this TopoJSON file as a source in Power BI Desktop? Is this possible in Power BI? Is it the correct way to do it?
Why do we need a source file (such as Excel, CSV, SQL, etc..) on top of the TopoJSON file since the TopoJSON file itself has data in it?
Please apologize me if the questions are not sensible, I am trying to understand how this process works?
Thanks in advance.
Solved! Go to Solution.
The TopoJSON used for the Shape Map visual is not part of the data model. It's unique to the visual and meant to map data in the data model to shapes on the map. *Why* the product team chose to do it that way is not something I can answer.
You can grab the data from the TopoJSON file using the JSON connector in Power BI Desktop, then expand through a series of columns to get the data. I have a sample M script from another post where I answered a similar question:
let Source = Json.Document(File.Contents("C:\[...]\icitw_wgs84.json")), objects = Source[objects], icitw_wgs1 = objects[icitw_wgs84], geometries = icitw_wgs1[geometries], #"Converted to Table" = Table.FromList(geometries, Splitter.SplitByNothing(), null, null, ExtraValues.Error), #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"arcs", "type", "properties"}, {"Column1.arcs", "Column1.type", "Column1.properties"}), #"Expanded Column1.properties" = Table.ExpandRecordColumn(#"Expanded Column1", "Column1.properties", {"GEO_ID", "CREATE_ID", "NAME", "SCODE_NAME", "LCODE_NAME", "TYPE_DESC", "TYPE_CODE", "OBJECTID", "SHAPE_AREA", "SHAPE_LEN"}, {"Column1.properties.GEO_ID", "Column1.properties.CREATE_ID", "Column1.properties.NAME", "Column1.properties.SCODE_NAME", "Column1.properties.LCODE_NAME", "Column1.properties.TYPE_DESC", "Column1.properties.TYPE_CODE", "Column1.properties.OBJECTID", "Column1.properties.SHAPE_AREA", "Column1.properties.SHAPE_LEN"}), #"Removed Columns" = Table.RemoveColumns(#"Expanded Column1.properties",{"Column1.arcs", "Column1.type", "Column1.properties.GEO_ID", "Column1.properties.CREATE_ID"}), #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Column1.properties.NAME", "Ward Name"}, {"Column1.properties.SCODE_NAME", "SCODE NAME"}, {"Column1.properties.LCODE_NAME", "LCODE NAME"}, {"Column1.properties.TYPE_DESC", "TYPE CODE"}}), #"Removed Columns1" = Table.RemoveColumns(#"Renamed Columns",{"TYPE CODE", "Column1.properties.TYPE_CODE", "Column1.properties.SHAPE_AREA", "Column1.properties.SHAPE_LEN"}), #"Renamed Columns1" = Table.RenameColumns(#"Removed Columns1",{{"Column1.properties.OBJECTID", "Object ID"}}) in #"Renamed Columns1
The TopoJSON used for the Shape Map visual is not part of the data model. It's unique to the visual and meant to map data in the data model to shapes on the map. *Why* the product team chose to do it that way is not something I can answer.
You can grab the data from the TopoJSON file using the JSON connector in Power BI Desktop, then expand through a series of columns to get the data. I have a sample M script from another post where I answered a similar question:
let Source = Json.Document(File.Contents("C:\[...]\icitw_wgs84.json")), objects = Source[objects], icitw_wgs1 = objects[icitw_wgs84], geometries = icitw_wgs1[geometries], #"Converted to Table" = Table.FromList(geometries, Splitter.SplitByNothing(), null, null, ExtraValues.Error), #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"arcs", "type", "properties"}, {"Column1.arcs", "Column1.type", "Column1.properties"}), #"Expanded Column1.properties" = Table.ExpandRecordColumn(#"Expanded Column1", "Column1.properties", {"GEO_ID", "CREATE_ID", "NAME", "SCODE_NAME", "LCODE_NAME", "TYPE_DESC", "TYPE_CODE", "OBJECTID", "SHAPE_AREA", "SHAPE_LEN"}, {"Column1.properties.GEO_ID", "Column1.properties.CREATE_ID", "Column1.properties.NAME", "Column1.properties.SCODE_NAME", "Column1.properties.LCODE_NAME", "Column1.properties.TYPE_DESC", "Column1.properties.TYPE_CODE", "Column1.properties.OBJECTID", "Column1.properties.SHAPE_AREA", "Column1.properties.SHAPE_LEN"}), #"Removed Columns" = Table.RemoveColumns(#"Expanded Column1.properties",{"Column1.arcs", "Column1.type", "Column1.properties.GEO_ID", "Column1.properties.CREATE_ID"}), #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Column1.properties.NAME", "Ward Name"}, {"Column1.properties.SCODE_NAME", "SCODE NAME"}, {"Column1.properties.LCODE_NAME", "LCODE NAME"}, {"Column1.properties.TYPE_DESC", "TYPE CODE"}}), #"Removed Columns1" = Table.RemoveColumns(#"Renamed Columns",{"TYPE CODE", "Column1.properties.TYPE_CODE", "Column1.properties.SHAPE_AREA", "Column1.properties.SHAPE_LEN"}), #"Renamed Columns1" = Table.RenameColumns(#"Removed Columns1",{{"Column1.properties.OBJECTID", "Object ID"}}) in #"Renamed Columns1
Thank You. Much appreciate your response.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
100 | |
83 | |
76 | |
65 |
User | Count |
---|---|
120 | |
111 | |
94 | |
83 | |
77 |