用于 Power BI 地图可视化效果的提示和技巧Tips and Tricks for Power BI Map visualizations

Power BI 与必应地图集成,提供默认地图坐标(一种称为“地理位置编码”的过程),以便用户可以创建地图。Power BI integrates with Bing Maps to provide default map coordinates (a process called geo-coding) so you can create maps. 集成后,它们使用算法共同确定正确的位置,但有时只是一种最佳猜测。Together they use algorithms to identify the correct location, but sometimes it's a best guess. 如果 Power BI 无法尝试自行创建地图可视化效果,则会借助必应地图的帮助。If Power BI tries can't create the map visualization on its own, it enlists the help of Bing Maps.

若要增加地理编码正确的可能性,可使用以下提示。To increase the likelihood of correct geo-coding, use the following tips. 第一组提示适合在有权访问数据集本身时参考。The first set of tips is for you to use if you have access to the dataset itself. 第二组提示则说明了当无权访问数据集时可以在 Power BI 中执行的操作。And the second set of tips is things you can do in Power BI if you don't have access to the dataset.

哪些数据会发送给必应地图?What is sent to Bing Maps?

Power BI 服务和 Power BI Desktop 向必应发送创建地图可视化效果所需的地理位置数据。Power BI service and Power BI Desktop send Bing the geo data it needs to create the map visualization. 这可能包括“位置”、“纬度”和“经度”存储桶中的数据,以及任何“报表级别”、“页级别”或“视觉对象级别”筛选器存储桶中的地理字段。This may include the data in the Location, Latitude, and Longitude buckets and geo fields in any of the Report level, Page level, or Visual level filter buckets. 发送的确切内容因地图类型而异。Exactly what is sent varies by map type. 若要了解详细信息,请参阅必应地图隐私To learn more, see Bing Maps privacy.

  • 对于地图(气泡图),如果提供了纬度和经度,则不会向必应发送任何数据。For maps (bubble maps), if latitude and longitude are provided then no data is sent to Bing. 否则,将会向必应发送“位置”(和筛选器)Bucket 中的所有数据。Otherwise, any data in the Location (and filter) buckets is sent to Bing.
  • 着色地图需要获取“位置”Bucket 中的字段;即使已提供纬度和经度,也不例外。Filled maps require a field in the Location bucket; even if latitude and longitude are provided. “位置”、“纬度”或“经度”Bucket 中的所有数据都会发送给必应。Whatever data is in the Location, Latitude, or Longitude buckets is sent to Bing.

    在下面的示例中,字段“供应商”用于地理编码,因此所有供应商数据都会发送到必应。In the example below, the field Vendor is being used for geo-coding, so all vendor data is sent to Bing. “大小”和“颜色饱和度”存储桶中的数据不会发送到必应。Data from the Size and Color saturation buckets is not sent to Bing.


    在下面的第二个示例中,由于字段“区域”用于地理位置编码,因此所有区域数据都会发送给必应。In this second example below, the field Territory is being used for geo-coding, so all territory data is sent to Bing. “图例”和“色彩饱和度”Bucket 中的数据不会发送给必应。Data from the Legend and Color saturation buckets is not sent to Bing.


在数据集中:改进基础数据集的提示In the dataset: tips to improve the underlying dataset

如果你有权访问正用于创建地图可视化效果的数据集,可以执行以下几项操作,从而增加地理编码不出错的可能性。If you have access to the dataset that is being used to create the map visualization, there are a few things you can do to increase the likelihood of correct geo-coding.

1.在 Power BI Desktop 中对地理字段进行分类1. Categorize geographic fields in Power BI Desktop

在 Power BI Desktop 中,可以通过设置数据字段上的“数据类别”来确保字段进行了正确地理编码。In Power BI Desktop, you can ensure fields are correctly geo-coded by setting the Data Category on the data fields. 选择相应的表,转到“高级”功能区,再将“数据类别”设置为“地址”、“城市”、“洲”、“国家/区域”、“县”、“邮政编码”、“州”或“省/自治区/直辖市”。Select the desired table, go to the Advanced ribbon and then set the Data Category to Address, City, Continent, Country/Region, County, Postal Code, State or Province. 这些数据分类有助于必应对日期进行正确编码。These data categories help Bing correctly encode the date. 若要了解详细信息,请参阅 Power BI Desktop 中的数据分类To learn more, see Data categorization in Power BI Desktop. 若要实时连接到 SQL Server Analysis Services,需要使用 SQL Server Data Tools (SSDT),在 Power BI 外部设置数据分类。If you are live connecting to SQL Server Analysis Services, you will need to set the data categorization outside of Power BI using SQL Server Data Tools (SSDT).

2.使用多个位置列。 2. Use more than one location column.
有时,即使对地图设置数据分类也不足以使必应正确地猜测你的目标。Sometimes, even setting the data categories for mapping isn't enough for Bing to correctly guess your intent. 某些地理标记不明确,因为多个国家/区域都有相应的地理位置。Some designations are ambiguous because the location exists in multiple countries or regions. 例如,英格兰、宾夕法尼亚州和纽约州都有南安普敦。For example, there's a Southampton in England, Pennsylvania, and New York.

Power BI 使用必应的非结构化 URL 模板服务,来基于一组任何国家/地区的地址值获取纬度和经度坐标。Power BI uses Bing's unstructured URL template service to get the latitude and longitude coordinates based on a set of address values for any country. 如果数据未包含足够的位置数据,请适当地添加这些列并对它们进行分类。If your data doesn't contain enough location data, add those columns and categorize them appropriately.

例如,如果只有一个“城市”列,必应可能会在进行地理位置编码时遇到困难。For example, if you only have a City column, Bing may have a hard time geo-coding. 请添加其他地理位置列,以便可以明确确定位置。Add additional geo columns to make the location unambiguous. 有时,只需向数据集再添加一个位置列(在此示例中,即为“州/省/自治区/直辖市”)即可。Sometimes all it takes is adding one more location column to the dataset - in this case state/province. 另外,也不要忘了进行正确分类,请参阅上面的第 1 条提示。And don't forget to categorize it properly, see #1 above.

确保每个字段仅具有与分类关联的具体信息。Make sure when each field only has the specific information tied to the categorization. 例如,你的“城市”位置字段应为“南安普敦”,而非“南安普敦、纽约”。For example, your City location field should be Southampton, not Southampton, New York. 而“地址”位置字段应为“1 Microsoft Way”而非“1 Microsoft Way, Redmond, WA”。And Address location fields should be 1 Microsoft Way and not 1 Microsoft Way, Redmond, WA.

3.使用特定的纬度和经度3. Use specific Latitude and Longitude

向数据集添加纬度和经度值。Add latitude and longitude values to your dataset. 这将删除任何不确定的数据并更快地返回结果。This removes any ambiguity and returns results more quickly. 纬度和经度字段必须为十进制数格式,你可以在数据模型中进行设置。Latitude and Longitude fields must be in Decimal Number format, which you can set in the data model.

4.将“地点”类别用于具有完整位置信息的列4. Use Place category for columns with full location information

虽然我们鼓励在地图中使用地理层次结构,但如果必须使用包含完整地理信息的单个位置列,可以将数据分类设置为“地点”。While we encourage you to use geo-hierarchies in your maps, if you must use a single location column with full geographical information, you can set the data categorization to Place. 例如,如果列中的数据是完整地址(例如,1 Microsoft Way, Redmond Washington 98052),则这个全面的数据类别最适合用于必应。For example, if the data in your column is full addresses, such as 1 Microsoft Way, Redmond Washington 98052, this generalized data category will work best with Bing.

在 Power BI 中:使用地图可视化效果时提高结果准确性的提示In Power BI: tips to get better results when using map visualizations

1.使用纬度和经度字段(若有)1. Use latitude and longitude fields (if they exist)

在 Power BI 中,如果所使用的数据集包含经度和纬度字段,请使用此类字段!In Power BI, if the dataset you are using has fields for longitude and latitude -- use them! Power BI 提供有助于明确地图数据的特殊 Bucket。Power BI has special buckets to help make the map data unambiguous. 只需将包含纬度数据的字段拖到“可视化效果>纬度”区域中即可。Just drag the field that contains your latitude data into the Visualizations > Latitude area. 对经度数据执行相同操作。And do the same for your longitude data. 执行此操作时,你还需要在创建可视化效果时填充位置字段。When you do this, you also need to fill the Location field when creating your visualizations. 否则,数据将默认进行聚合,例如,将在州级别而不是市级别配对经纬度。Otherwise, the data is aggregated by default, so for example, the latitude and longitude would be paired at the state level, not the city level.


使用地理位置层次结构,以便可以向下钻取到不同的位置“级别”Use geo-hierarchies so you can drill down to different "levels" of location

如果数据集已有不同级别的位置数据,你和同事可以使用 Power BI 创建地理位置层次结构。When your dataset already has different levels of location data, you and your colleagues can use Power BI to create geo-hierarchies. 为此,请将多个字段拖到“位置”Bucket 中。To do this, drag more than one field into the Location bucket. 通过这种方式结合使用,字段将构成地理位置层次结构。Used together in this way, the fields become a geo-hierarchy. 在下面的示例中,我们已添加了“国家/地区”、“州/省/自治区/直辖市”和“城市”地理位置字段。In the example below we have added geo fields for: Country/Region, State, and City. 在 Power BI 中,你和同事可以使用此地理位置层次结构,向上和向下钻取到不同的位置级别。In Power BI you and your colleagues can drill up and down using this geo-hierarchy.



使用地理层次结构进行钻取时,请务必了解每个钻取按钮的工作原理和发送到必应地图的内容。When drilling with geo-hierarchies, it is important to know how each drill button works and what gets sent to Bing Maps.

  • 钻取按钮位于最右侧,称为“深化模式”,可以使用它选择地图位置并向下钻取到该特定位置,每次钻取一级。The drill button on the far right, called Drill Mode , allows you to select a map Location and drill down into that specific location one level at a time. 例如,如果启用“向下钻取”并单击“北美”,会向下移动到层次结构的下一级,即北美的各个州。For example, if you turn Drill Down on and click North America, you move down in the hierarchy to the next level -- states in North America. 对于地理编码,Power BI 仅发送必应地图中北美的国家/地区和州数据。For geo-coding, Power BI sends Bing Maps country and state data for North America only.
  • 左侧还有另外 2 个钻取选项。On the left there are 2 other drill options. 第一个选项 可用于立即钻取到所有位置中层次结构的下一级。The first option, , drills to the next level of the hierarchy for all locations at once. 例如,如果你当前正在查看国家/地区,然后使用此选项移动到下一级:州,则 Power BI 会显示所有国家/地区的州数据。For example, if you are currently looking at countries and then use this option to move to the next level, states, Power BI displays state data for all countries. 对于地理编码,Power BI 会发送必应地图中所有地区的州数据(无国家/地区数据)。For geo-coding, Power BI sends Bing Maps state data (no country data) for all locations. 如果层次结构的每一级与更高的级别不相关,则此选项非常有用。This option is useful if each level of your hierarchy is unrelated to the level above it.
  • 第二个选项,The second option, 使用地图向下钻取 类似于向下钻取,但无需在地图上进行单击。, is similar to Drill Down, except that you don't need to click on the map. 它会向下扩展到记住当前级别的上下文的下一级层次结构。It expands down to the next level of the hierarchy remembering the current level’s context. 例如,如果你当前正在看国家/地区并选择此图标,则会在层次结构中向下移动到下一级:州。For example, if you are currently looking at countries and select this icon, you move down in the hierarchy to the next level -- states. 对于地理编码,Power BI 会发送每个州的数据及其对应的国家/地区,帮助必应地图更准确地进行地理编码。For geo-coding, Power BI sends data for each state and its corresponding country to help Bing Maps geocode more accurately. 在大部分地图中会使用此选项或最右侧的“向下钻取”选项,以便能够向必应发送尽可能多的信息以获取准确的位置信息。In most maps, you will use either this option or the Drill Down option on the far right, so you can send Bing as much information as possible to get accurate location information.

后续步骤Next steps

在 Power BI 可视化效果中向下钻取Drill down in a Power BI visualization

Power BI 可视化效果Power Bi visualizations

更多问题?More questions? 尝试参与 Power BI 社区Try the Power BI Community