Power BI Map 視覺效果的秘訣和訣竅Tips and Tricks for Power BI Map visualizations

Power BI 與 Bing 地圖服務整合以提供預設地圖座標 (這個程序稱為地理編碼),以便您建立地圖。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 無法自行建立地圖視覺效果,則會請求 Bing 地圖服務協助。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.

傳送至 Bing 地圖服務的項目What is sent to Bing Maps?

Power BI 服務和 Power BI Desktop 會將 Bing 建立地圖視覺效果所需的地理資料傳送至 Bing。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. 若要深入了解,請參閱 Bing 地圖服務隱私權To learn more, see Bing Maps privacy.

  • 以地圖來說 (泡泡地圖),如果提供緯度和經度,則不會將資料傳送至 Bing。For maps (bubble maps), if latitude and longitude are provided then no data is sent to Bing. 否則,位置 貯體中的任何資料會傳送至 Bing。Otherwise, any data in the Location (and filter) buckets is sent to Bing.
  • 區域分布圖需要 [位置] 貯體中的欄位,即使提供緯度和經度亦然。Filled maps require a field in the Location bucket; even if latitude and longitude are provided. [位置]、[緯度] 或 [經度] 貯體中的資料都會傳送至 Bing。Whatever data is in the Location, Latitude, or Longitude buckets is sent to Bing.

    在下列範例中,[廠商] 欄位用於地理編碼,因此會將所有廠商資料傳送至 Bing。In the example below, the field Vendor is being used for geo-coding, so all vendor data is sent to Bing. [大小] 和 [色彩飽和度] 貯體中的資料不會傳送至 Bing。Data from the Size and Color saturation buckets is not sent to Bing.

    傳送至 Bing 地圖服務

    在下列第二個範例中,[領域] 欄位用於地理編碼,因此會將所有領域資料傳送至 Bing。In this second example below, the field Territory is being used for geo-coding, so all territory data is sent to Bing. [圖例] 和 [色彩飽和度] 貯體中的資料不會傳送至 Bing。Data from the Legend and Color saturation buckets is not sent to Bing.

    區域分布圖和 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. 這些資料類別可以協助 Bing 將該日期正確編碼。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.
有時候,即使設定了地圖的資料分類,也不夠讓 Bing 正確猜出您的意圖。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 會使用 Bing 的非結構化 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.

例如:如果您只有 [鄉/鎮/市/區] 資料行,Bing 可能很難進行地理編碼。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. 此外,別忘了將它正確分類,如上面第一項所述。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,雷德蒙德,WAAnd 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,雷德蒙德,華盛頓州 98052」,則這個通用資料分類與 Bing 搭配的效果將會最好。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 具有特殊貯體,可協助讓地圖資料更明確。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. 若要這樣做,請將多個欄位拖曳到 [位置] 貯體中。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.

[位置] 欄位

建立地圖的地理階層

當您在切入地理階層架構時,請務必了解每個切入按鈕的運作方式為何,以及您將會傳送什麼資料給 Bing 地圖服務。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 僅會將北美洲的國家/地區及各州/省的資料傳送給 Bing 地圖服務。For geo-coding, Power BI sends Bing Maps country and state data for North America only.
  • 左邊則有另外兩個切入選項。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 會將所有位置的州/省資料傳送給 Bing 地圖服務 (不包含國家/地區資料)。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 會將每個州/省的資料及其對應的國家/地區資料傳送給 Bing 地圖服務,以協助其更準確的進行地理編碼。For geo-coding, Power BI sends data for each state and its corresponding country to help Bing Maps geocode more accurately. 在大多數的地圖中,您通常會使用這個選項或最右邊的 [向下切入] 選項,盡量將最多的資料傳送給 Bing,以取得準確的位置資訊。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