Sub topic 6
Showing parts of a whole
Composition questions ask how a total divides into parts. Examples are "What share of revenue does each category bring in?" and "How did we get from last year's profit to this year's?" This chapter covers the built-in Power BI visuals for these questions, the measures they need, and the situations where they mislead.
Prerequisites
This chapter assumes you can do the following:
- Build a basic visual on the Power BI Desktop canvas and use the field wells.
- Work with a loaded model that has related tables, such as
Sales,ProductandDate. - Write simple DAX measures and know the difference between a column and a measure.
The previous chapters covered bar charts and the question-first approach. Here we build on the idea that composition is a comparison with a constraint: the parts must add up to a meaningful whole.
Absolute values and shares
Before you pick a visual, decide which of two things you want to show.
- Absolute values show how large each part is. A stacked bar of sales by category does this.
- Shares show each part as a fraction of the whole. A measure that returns a percentage does this.
A visual can show both, but it should emphasize one. If the reader needs to know that Bikes is 61% of sales, give them a percentage. If they need to know it is 12.4 million, show the amount.
The share measure below divides a category's sales by the sales of all categories. ALL ( Product[Category] ) removes the category filter from the denominator, so the denominator stays constant for every bar or slice.
Sales % of Total =
DIVIDE (
[Total Sales],
CALCULATE ( [Total Sales], ALL ( Product[Category] ) )
)This measure assumes [Total Sales] already exists:
Total Sales = SUM ( Sales[SalesAmount] )Format Sales % of Total as a percentage in the Measure tools ribbon. DIVIDE returns blank instead of an error when the denominator is zero or blank.
Choosing among the composition visuals
| Visual | Best for | Limit |
|---|---|---|
| Stacked bar or column | Parts of a whole across a few categories | Only the bottom segment shares a baseline, so middle segments are hard to compare |
| 100% stacked bar or column | Comparing shares across groups | Hides the absolute size of each group |
| Donut chart | A few parts (about 2 to 5) of one whole | Angles and arc lengths are hard to compare accurately |
| Pie chart | The same as donut, with the same limits | Many slices become unreadable |
| Treemap | Many parts of a hierarchy, where rough size is enough | Precise comparison is poor, and small tiles lose their labels |
| Waterfall | A bridge from a start value to an end value | Needs a clear sequence of increases and decreases |
Stacked bar and column charts
A stacked chart puts a second field in the Legend well and splits each bar into segments. Use it when you want both the total per bar and the makeup of that total.
The main weakness is the baseline. Readers compare bar lengths easily when bars start at the same point. In a stacked chart, only the first segment starts at zero. The other segments float, so comparing them across bars is difficult.
Practical guidance:
- Keep the number of segments to about five or fewer.
- Put the segment you care about most at the bottom, next to the baseline. You can control the stacking order through the sort order of the Legend field.
- If the comparison of segments across bars matters most, use a clustered chart or small multiples instead.
100% stacked charts
A 100% stacked chart scales every bar to the same length, so every bar shows shares only. Use it to compare mix across groups, such as the share of sales by channel in each region.
The cost is that total size disappears. A region with 1 million in sales looks the same length as one with 100 million. If size also matters, add the totals in a tooltip or a nearby bar chart.
Donut and pie charts
Donut and pie charts suit one question: how does a small number of parts split one whole? They work when there are two to five slices, the differences are large, and you label each slice with its value or percentage.
They fail in these cases:
- Many slices, especially more than six.
- Slices of similar size, which the eye cannot rank.
- Comparing several wholes. Two donuts side by side force the reader to compare angles across charts.
A sorted bar chart using Sales % of Total answers the same question with better accuracy. If a pie or donut with many slices appears in a report, replace it with a bar chart ranked by share.
Treemap
A treemap draws each part as a rectangle whose area is proportional to its value. Nested rectangles show a hierarchy, such as Category and then Subcategory.
Use a treemap when:
- You have many parts, perhaps 10 to 50.
- The reader needs the big picture and the largest contributors, not exact numbers.
- The data has a natural hierarchy.
Avoid it when exact comparison matters. Area is harder to judge than length. Negative values cannot be shown, because area cannot be negative. If the data contains negative values, filter them out deliberately or choose another visual.
Waterfall chart
A waterfall shows how an initial value turns into a final value through a series of increases and decreases. It fits profit bridges (revenue, minus costs, minus tax, equals profit) and period-to-period changes (last year's sales, plus growth by region, equals this year's sales).
Setup:
- Put the category or step in the Category well. You can use a Breakdown field to expand the largest contributors.
- Put a measure in the Y-axis well.
- Turn on Sentiment colors so increases and decreases are clearly distinguished.
A waterfall only makes sense when the steps are ordered and the values are changes. For a bridge across time, put a date field in the Category well. For a bridge across categories, sort the categories by size so the biggest steps come first.
Comparing composition to a prior period
Composition often needs context. A share of 40% means little until the reader knows it was 35% last year. Reuse the prior-year measure from the trend chapter. It requires a date table that is marked as a date table:
Sales LY =
CALCULATE ( [Total Sales], SAMEPERIODLASTYEAR ( 'Date'[Date] ) )The year-over-year percentage change then comes from a second measure:
Sales YoY % =
DIVIDE ( [Total Sales] - [Sales LY], [Sales LY] )Use these in a waterfall (with Category as the breakdown) to show which categories drove the change, or in a tooltip on a stacked chart.
Decision flow
Common errors
- Percentages that do not add to 100. Rounded labels can sum to 99 or 101. Show one decimal place, or accept the rounding and note it.
- Share measure that changes when you filter. If the denominator uses
ALL ( Product[Category] ), a slicer on Category will not change it, but a slicer on Year will. That is usually what you want, but test it. If the share should be of the visible total, useALLSELECTEDinstead ofALL. - Treemap with negative values. The negative tiles are dropped or distort the picture. Check the data before choosing it.
- Pie chart used for time. Parts of a whole across time belong in a stacked area or 100% stacked column chart, not in a row of pies.
- Too many legend entries. Group the small categories into an "Other" bucket, either in the model or with a Power BI grouping, so the main parts stay legible.
- Using a waterfall for non-additive values. Averages and ratios do not add up. Use a waterfall for sums and counts.
Worked example
You are asked: "Which product categories make up our sales, and how did they change from last year?"
- Identify the task. It is composition, plus a change over time.
- Create
Total Sales,Sales % of Total,Sales LYandSales YoY %. - Put
Product[Category]on the Y-axis of a bar chart andSales % of Totalin the X-axis well. Sort descending by value. - Add
Sales YoY %to the Tooltips well. - If the question becomes "How did total sales go from last year to this year?", switch to a waterfall with
Product[Category]as the Category and a change measure as the Y-axis.
The result is a ranked, labeled view where the biggest contributor is at the top and the reader can find the change by hovering.
Exercise
A report shows a pie chart of sales across 14 product subcategories. Readers say they cannot tell which subcategories are largest. Name two replacement visuals, say when you would choose each, and give the DAX measure that supplies the share for one of them.
Show answer
Replace it with a bar chart sorted by value, using the measure Sales % of Total = DIVIDE ( [Total Sales], CALCULATE ( [Total Sales], ALL ( Product[Subcategory] ) ) ). Choose the bar chart when readers need to rank and compare the subcategories accurately. Alternatively, choose a treemap when the subcategories sit in a hierarchy (for example under Category) and readers only need the large contributors, not exact values. Note that the ALL call must name the field that is on the axis, Product[Subcategory], so the denominator ignores the subcategory filter.
Exercise
You want to show how profit moved from 2.0 million last year to 2.6 million this year, split by region. Which visual do you use, and what must be true of the values you place in it?
Show answer
Use a waterfall chart with Region in the Category well and a measure for each region's change in profit in the Y-axis well. The values must be additive changes, so that the start value plus all the regional changes equals the end value. Sort the regions by the size of the change so the biggest steps appear first.