Power BI Desktop 中的資料分類Data categorization in Power BI Desktop

Power BI Desktop 中,您可以指定資料行的資料類別,讓 Power BI Desktop 知道如何在視覺效果中處理其值。In Power BI Desktop, you can specify the Data Category for a column so Power BI Desktop knows how it should treat its values when in a visualization.

當 Power BI Desktop 匯入資料時,不只會取得資料本身,也會取得資料表和資料行名稱等資訊,像是主索引鍵等。有了該資訊之後,Power BI Desktop 便可做出某種程度的假設,讓您在建立視覺效果時可以有最佳的預設體驗。When Power BI Desktop imports data, not only does it get the data itself, it also gets information such as the table and column names, whether it’s a primary key, etc. With that information, Power BI Desktop makes some assumptions about how to give you a good default experience when creating a visualization.

以下舉例説明:當 Power BI Desktop 偵測到某個資料行具有數值時,您可能會想要以某種方式進行彙總,因此會將資料行置於 [值] 區域。Here’s an example: When Power BI Desktop detects a column has numeric values, you’ll probably want to aggregate it in some way, so it’s placed in the Values area. 或者,如果資料行具有日期時間值,它會假設您可能要以此資料行做為折線圖上的時間階層軸。Or, for a column with date time values, it assumes you’ll probably use it as a time hierarchy axis on a line chart.

不過有些情況較具挑戰性,例如地理位置。But, there are some cases that are a bit more challenging, like geography. 請考慮以下來自 Excel 工作表的資料表:Consider the following table from an Excel worksheet:

Power BI Desktop 應該將 GeoCode 資料行中的代碼視為國家/地區或美國州名的縮寫?Should Power BI Desktop treat the codes in the GeoCode column as an abbreviation for a Country or a US State? 由於這種代碼可能代表任何意思,因此並不清楚。It’s not clear because a code like this can mean either one. 例如,AL 可能表示阿拉巴馬州或阿爾巴尼亞,AR 可能表示阿肯色州或阿根廷,CA 可能表示加州或加拿大。For instance, AL can mean Alabama or Albania, AR can mean Arkansas or Argentina, or CA can mean California or Canada. 當我們在地圖上繪製 GeoCode 欄位時,則需要加以區別。It makes a difference when we go to chart our GeoCode field on a map. Power BI Desktop 應該顯示醒目提示國家/地區的世界圖片,或醒目提示各州的美國圖片?Should Power BI Desktop show a picture of the world with countries highlighted or a picture of the United States with states highlighted? 您可以為此指定資料的資料類別。You can specify a Data Category for data just like this. 資料分類會進一步精簡 Power BI Desktop 可用來提供最佳視覺效果的資訊。Data categorization further refines the information Power BI Desktop can use to provide the best visualizations.

指定資料類別To specify a Data Category

  1. 在 [報表檢視] 或 [資料檢視] 的 [欄位] 清單中,選取您要依不同分類排序的欄位。In Report View or Data View, in the Fields list, select the field you want to be sorted by a different categorization.
  2. 在功能區的 [資料工具模型化] 索引標籤中,按一下 [資料類別:] 下拉式清單。On the ribbon, in the Data Tools Modeling tab, click on the Data Category: drop down list. 這會顯示您可以為資料行選擇的所有可能資料類別清單。This shows the list of possible data categories you can choose for your column. 如果某些選項不適用於資料行的目前資料類型,則可能會停用這些選項。Some selections might be disabled if they won’t work with the current data type of your column. 例如,如果資料行是二進位資料類型,Power BI Desktop 將無法讓您選擇地理資料類別。For example, if a column is a binary data type, Power BI Desktop won’t let you choose geographic data categories.

這樣就大功告成了!And that’s it! 通常導致視覺效果的任何行為現在會自動運作。Any behavior that normally accrues to a visual will now work automatically.

您可能也會想要了解 Power BI 行動裝置應用程式的地理篩選You might also be interested in learning about geographic filtering for Power BI mobile apps.