Sub topic 9
When a table or matrix is the right answer
This chapter assumes you can build a basic visual on the Power BI Desktop canvas and that your model already has related tables. It also assumes you know what the field wells are and have written a simple measure such as [Total Sales].
What tables and matrices are for
Charts show patterns. Tables and matrices show exact values. Choose one when the reader needs to look up a number, check a record, or scan many fields at once. They also suit cases where no single chart fits, such as comparing several measures that use different units.
- A table is a flat list. Each row is one combination of the fields you add, and each column is one field or measure.
- A matrix is a cross-tab. It puts one field on rows, another on columns, and measures in the cells. It also supports expanding and collapsing a hierarchy and shows subtotals and grand totals.
Choosing between them
| Situation | Better choice |
|---|---|
| List orders, customers or products with several attributes | Table |
| Exact values for a few measures by one category | Table |
| Categories down the side, periods or segments across the top | Matrix |
| Drill from Category to Subcategory to Product inside one visual | Matrix |
| Subtotals and grand totals matter | Matrix |
Worked example: a sales matrix
Use the base measure from earlier chapters and the year-over-year percentage measure:
Total Sales = SUM ( Sales[SalesAmount] )Sales YoY % =
DIVIDE ( [Total Sales] - [Sales LY], [Sales LY] )Build the matrix like this:
- Add a Matrix visual to the canvas.
- Put
Product[Category]and thenProduct[Subcategory]in Rows. - Put
'Date'[Year]in Columns. - Put
[Total Sales]in Values.
The reader can now see sales by category and year, and expand a category to see its subcategories. Add [Sales YoY %] to Values to show growth next to each amount. By default the measures appear as separate column groups under each year. Under Format > Values, you can instead place them on rows.
Making the visual readable
- Turn on Conditional formatting (background color, data bars or icons) for the key measure. It brings back some of the pattern-spotting a chart gives.
- Format percentages and currency in the measure's format settings, so every cell is consistent.
- Sort by the measure rather than alphabetically when ranking matters.
- Limit the number of columns. A wide matrix forces horizontal scrolling and hides the main point.
Common errors
- Using a table as a dump. Twenty unsorted columns answer no question. Pick the fields that serve one purpose.
- Summed numeric columns. If a field such as
ListPriceis added to a table without choosing a summarization, Power BI may sum it. Set it to Don't summarize to see row-level values, or use an average. - Totals that mislead. A percentage measure's total is calculated on the totals, not by adding the rows. Check that the total row makes sense, or turn it off.
- Blank year-over-year cells.
[Sales LY]needs a marked date table. Without one, the prior-year values come back blank or wrong.
Exercise
A manager wants to see revenue for each product category (rows) across the four quarters (columns), with a grand total, and wants to expand a category into its products. Which visual do you use, and which fields go in Rows and Columns?
Show answer
Use a matrix. Put Product[Category] and then Product[Product] in Rows, the quarter field from the date table in Columns, and [Total Sales] in Values. The matrix supplies the totals and the expand and collapse behavior.