在 Power BI 報表和儀表板使用資料 (教學課程)Working with tables in Power BI reports and dashboards (Tutorial)

資料表是一個方格,其中以資料列和資料行的邏輯數列包含相關的資料。A table is a grid that contains related data in a logical series of rows and columns. 它也可能包含標頭和總計資料列。It may also contain headers and a row for totals. 資料表適合處理您要在許多值裡尋找單一類別的量化比較。Tables work well with quantitative comparisons where you are looking at many values for a single category. 例如,這個資料表會顯示類別的 5 個不同量值。For example, this table displays 5 different measures for Category.

使用資料表的時機When to use a table

資料表極適合:Tables are a great choice:

  • 查看並比較詳細資料和實際值 (而非視覺表示法)to see and compare detailed data and exact values (instead of visual representations)
  • 以表格格式顯示資料to display data in a tabular format
  • 依類別顯示數值資料to display numerical data by categories

注意

如果資料表有太多值,請考慮將它轉換成矩陣和/或使用向下鑽研。If a table has too many values, consider converting it to a matrix and/or using drilldown.

先決條件Prerequisites

  • Power BI 服務或 Power BI DesktopPower BI service or Power BI Desktop
  • 零售分析範例Retail Analysis sample

建立資料表Create a table

我們將建立上述的資料表,依項目類別顯示銷售值。We'll create the table pictured above to display sales values by item category. 若要跟著做,請登入 Power BI 服務並選取 [取得資料] > [範例] > [零售分析範例] > [連線],然後選擇 [移至儀表板]To follow along, sign in to Power BI service and select **Get Data > Samples > Retail Analysis Sample > Connect and choose **Go to dashboard. 建立視覺效果需要有資料集和報表的編輯權限。Creating a visualization requires edit permissions to the dataset and report. 幸運的是,所有的 Power BI 範例都是可編輯的。Luckily, the Power BI samples are all editable. 如果有報表已與您共用,您將無法在報表中建立視覺效果。If a report has been shared with you, you won't be able to create visualizations in reports.

  1. 從左側瀏覽窗格中,選取 [工作區] > [我的工作區]。From the left navpane, select Workspaces >My workspace.
  2. 選取 [資料集] 索引標籤,並向下捲動至您剛剛新增的 [零售分析範例] 資料集。Select the Datasets tab, and scroll down to the Retail Analysis Sample dataset you just added. 選取建立報表圖示。Select the Create report icon.

  3. 在報表編輯器中,選取 [項目] > [類別]。In the report editor, select Item > Category. Power BI 會自動建立資料表,列出所有類別。Power BI automatically creates a table that lists all the categories.

  4. 選取 [銷售] > [平均單價] 和 [銷售] > [去年度銷售額] 和 [銷售] > [本年度銷售額],並選擇所有 3 個選項 (值、目標、狀態)。Select Sales > Average Unit Price and Sales > Last Year Sales and Sales > This Year Sales and choose all 3 options (Value, Goal, Status).
  5. 在 [視覺效果] 窗格中,找出 [值] 並拖放值,直到您的圖表資料行順序符合此頁面上的第一個影像。In the Visualizations pane, locate the Values well and drag-and-drop the values until the order of your chart columns matches the first image on this page. 您的值應該看起來像這樣。Your Values well should look like this.

  6. 選取釘選圖示將資料表釘選到儀表板Pin the table to the dashboard by selecting the pin icon

格式化資料表Format the table

您可以透過許多方式格式化資料表,然而我們將只會討論其中幾種。There are many many ways to format a table and we'll only cover a few of them here. 若要了解其他格式化選項,建議您開啟 [格式化] 窗格 (滾筒刷圖示 ) 並進行探索。A great way to learn about the other formatting options is to open the Formatting pane (paint roller icon ) and explore.

  • 嘗試格式化資料表格線。Try formatting the table grid. 我們新增了一條藍色的垂直格線,將空白新增至資料列,並稍微增加了邊框及文字的大小。Here we've added a blue vertical grid, added space to the rows, increased the outline and text size a bit.

  • 針對資料行標頭,我們變更了背景色彩,新增了邊框,並增加了字型大小。For the column headers we changed the background color, added an outline, and increased the font size.

  • 在進行一些額外的格式化之後,以下是我們最後完成的資料表。And after some additional formatting, here is our final table. 由於您有許多可以使用的格式化選項,我們建議您從一個一般的資料表開始學習,開啟 [格式化] 窗格,並進行探索。Since there are so many formatting options, the best way to learn is to start with a plain table, open the Formatting pane , and start exploring.

條件式格式設定Conditional formatting

格式化的其中一種類型稱為 [條件式格式化設定],並會套用至 Power BI 服務或 Desktop [視覺效果] 窗格之 [值] 集區中的欄位。One type of formatting is referred to as conditional formatting and is applied to fields in the Values well of the Visualizations pane in Power BI service or Desktop.

設定資料表格式化的條件時,您可以根據資料格值指定自訂資料格背景色彩和字型色彩,包括使用漸層色彩。With conditional formatting for tables, you can specify customized cell background colors and font colors based on cell values, including using gradient colors.

  1. 在 Power BI 服務或 Desktop [視覺效果] 窗格中,選取您要格式化的 [值] 集區中,值旁邊的向下箭號 (或以滑鼠右鍵按一下欄位)。In the Visualizations pane in Power BI service or Desktop, select the down-arrow beside the value in the Values well that you want to format (or right-click the field). 您只能管理 [欄位] 集區之 [值] 區域中的欄位條件式格式設定。You can only manage conditional formatting for fields in the Values area of the Fields well.

  2. 選取 [背景色階]。Select Background color scales. 在出現的對話方塊中,您可以設定色彩以及 [最小值] 和 [最大值]。In the dialog that appears, you can configure the color, as well as the Minimum and Maximum values. 如果您選取 [發散] 方塊,您也可以設定選擇性的「中間」值。If you select the Diverging box, you can configure an optional Center value as well.

    讓我們將一些自訂格式化套用至平均單位價格值。Let's apply some custom formatting to our Average Unit Price values. 選取 [發散],新增一些色彩,然後選擇 [確定]。Select Diverging, add some colors, and choose OK.

  3. 將一個新的欄位新增至同時具有正值及負值的資料表。Add a new field to the table that has both positive and negative values. 選取 [銷售額] > [總銷售額差異]。Select Sales > Total Sales Variance.

  4. 透過選取 [總銷售額差異] 旁邊的向下箭頭,並選擇 [條件式格式設定] > [資料橫條] 來新增資料橫條條件式格式設定。Add data bar conditional formatting by selecting the down-arrow beside Total Sales Variance and choosing Conditional formatting > Data bars.

  5. 在出現的對話方塊中,設定 [正值橫條] 與 [負值橫條] 的色彩,在 [只顯示橫條] 旁邊進行勾選,並完成您想要的其他變更。In the dialog that appears, set colors for Positive bar, Negative bar, place a checkmark next to Show bar only, and make any other changes you'd like.

    當您選取 [確定] 之後,資料橫條就會取代資料表中的數值,使其變得更容易閱讀。When you select OK, data bars replace the numerical values in the table making it easier to scan.

  6. 若要從視覺效果移除設定格式化的條件,只要以滑鼠右鍵再按一次欄位,然後選取 [移除設定格式化的條件] 即可。To remove conditional formatting from a visualization, just right-click the field again, and select Remove Conditional Formatting.

提示

您也可以從格式化窗格 (滾筒刷圖示) 中存取條件式格式設定。Conditional formatting is also available from the Formatting pane (paintroller icon). 選取要格式化的值,然後將 [色階] 或 [資料橫條] 設定為 [開啟],以套用預設的設定;或者,您也可以藉由選取 [進階控制項] 來自訂設定。Select the value to format and then set Color scales or Data bars to On to apply the default settings or, to customize the settings, select Advanced controls.

調整資料表的資料行寬度Adjust the column width of a table

有時候 Power BI 會截斷報表和儀表板的資料行標題。Sometimes Power BI will truncate a column heading in a report and on a dashboard. 若要顯示整個資料行名稱,請將滑鼠停駐在標題右邊的空間以顯示雙箭號,選取並拖曳。To show the entire column name, hover over the space to the right of the heading to reveal the double arrows, select and drag.

有其他問題嗎?More questions? 試試 Power BI 社群Try the Power BI Community