An animated age pyramid in Power BI, with three fields
Getting started with Pyramid Plume: prepare a population table, insert the visual, sort ages with no sort column, show shares and pick a year.
Lire en françaisIn short
What is an age pyramid? It is a horizontal bar chart that shows how a population splits by age and sex: one row per age (or age band), the youngest at the bottom, men on one side, women on the other. Its shape tells a story: a wide base for a young population, a bulge for a large generation (the baby boom), a dip for the births missing during a war.
Mini example. A town has 120 men and 115 women aged 0 to 19, and 40 men and 70 women aged 80 and over: the bottom row is almost symmetrical, the top one clearly leans toward women.
- What the visual does. Pyramid Plume draws this pyramid from three fields, puts ages in the right order with no sort column ("5-9" before "10-14", "100+" at the top), shows counts or percentages with each side's total; with premium (★), it groups single ages into bands and plays the years with a ▶ button: the pyramid changes before your eyes, like the animations of national statistics offices. The same visual also draws butterfly charts: two measures face to face (managers and employees, budget and actual).
- When to use it. Demographics of an area, age pyramid of a company's staff, of an association's members, of a hospital's patients; any comparison of two groups category by category.
- When to choose something else. More than two groups to compare, or one value over time: Bar Plume or Line Plume.
- What you will learn. Prepare a population table, create a measure, insert the visual, pick a year, show percentages and labels.
- What you need: Power BI Desktop, the Pyramid Plume visual installed (see the common basics), a table with an age, a sex and a number of people. The sample report PlumePyramid-EN, in your "Downloads" area, shows a 2020 pyramid with a territory slicer (page 1), a pyramid in %, a butterfly and a tornado (page 2), and the ★ features (page 3), including the pyramid animated from 1975 to 2050.
The data to provide
The shape. One row per age (or band), per sex and, if you want to animate, per year: an age, a sex, a year and a number of people.
| Year | Band | Sex | Residents |
|---|---|---|---|
| 2020 | 0-19 | Men | 120 |
| 2020 | 0-19 | Women | 115 |
| 2020 | 20-39 | Men | 98 |
| 2020 | 20-39 | Women | 101 |
| 2020 | 40-59 | Men | 131 |
| 2020 | 40-59 | Women | 136 |
| 2020 | 60-79 | Men | 92 |
| 2020 | 60-79 | Women | 104 |
| 2020 | 80+ | Men | 40 |
| 2020 | 80+ | Women | 70 |
To try without a file: Modeling › New table, then paste (year 2000 is used for the animation):
Population =
DATATABLE (
"Year", INTEGER, "Band", STRING, "Sex", STRING, "Residents", INTEGER,
{
{ 2000, "0-19", "Men", 131 }, { 2000, "0-19", "Women", 126 },
{ 2000, "20-39", "Men", 125 }, { 2000, "20-39", "Women", 122 },
{ 2000, "40-59", "Men", 110 }, { 2000, "40-59", "Women", 112 },
{ 2000, "60-79", "Men", 70 }, { 2000, "60-79", "Women", 84 },
{ 2000, "80+", "Men", 21 }, { 2000, "80+", "Women", 45 },
{ 2020, "0-19", "Men", 120 }, { 2020, "0-19", "Women", 115 },
{ 2020, "20-39", "Men", 98 }, { 2020, "20-39", "Women", 101 },
{ 2020, "40-59", "Men", 131 }, { 2020, "40-59", "Women", 136 },
{ 2020, "60-79", "Men", 92 }, { 2020, "60-79", "Women", 104 },
{ 2020, "80+", "Men", 40 }, { 2020, "80+", "Women", 70 }
}
)
The measure. The Value well expects a measure (a calculation that Power BI redoes for the current filters, written in DAX; see the glossary):
Number of residents = SUM ( Population[Residents] ) -- adds the residents of each age and each sex
Pitfalls.
- No need to make men negative (the usual stacked-bar trick): both sides start from the center. If your measure is already negative, the visual reads it as positive.
- The age can be a number (0, 1, 2… 100) or a text ("0-4", "5 to 9", "100+", "under 5"): the visual reads the number and sorts by itself. No sort column is needed.
- With several years in the table, pick one (slicer or filter); the play axis ★ year must be a column (a whole number or a date), not a measure.
Step by step
- Click the Pyramid Plume icon in the Visualizations pane: an empty visual appears with the hint "Add fields to get started".
- Drag
Population[Band]to Age (or age band, category). - Drag
Population[Sex]to Side (sex or any two-value field). - Drag the
Number of residentsmeasure to Value (or two measures face to face). The pyramid appears: men on the left, women on the right, "0-19" at the bottom, "80+" at the top, with each side's total and share at the top. - Add a slicer with
Population[Year]and pick 2020: the pyramid shows that year (without a slicer, it adds up every year of the table). - To put the ages on one side: Format › Category axis › Position = Left; Labels = Every 5 years for a lighter axis.
- To read shares instead of counts: Format › Pyramid › Displayed values › Show = % of the total population.
- To see the values: turn on Format › Data labels › Show.
- To put women on the left: Format › Pyramid › Displayed values › Swap sides. Headers and colors follow.
- Click a bar: the other visuals of the page filter on that band and sex; the selection stays when the year changes. Click an empty area to clear it.
Troubleshooting
| What you see | Likely cause | Fix |
|---|---|---|
| Bands are not in order | Labels without numbers ("Young", "Seniors") | The visual then keeps the model order: sort the column by an order column, or use labels with ages |
| Both sides carry the measure name | No field in Side: two measures face to face | Drag the sex to Side and keep a single measure in Value |
| Message "only … and … are drawn" | The Side field has more than two values (e.g. "Not stated") | Filter out the third value, or map it into a two-value column |
| The pyramid adds up every year | No year is selected | Filter one year with a slicer, or drag the year to Play axis ★ to animate it |
| With the play axis ★, bars jump from one year to the next without gliding | Animations turned off (Format › Style › Animations, or the system setting) | Turn animations back on; Format › Playback ★ › Animated transitions must be on too |
| No label although Show is on | Rows too short (many single ages) | Lower Minimum row height, use bands in the data or group ages ★ (Format › Ages and categories › Group ages) |
Key takeaways
- Three fields are enough: Age, Side, Value; ages are ordered automatically.
- Everything on this page is free. A year in Play axis ★ animates the pyramid (premium feature, "Premium preview" watermark without a key).
- Counts, % of the total or % of each side: Format › Pyramid › Show.
- ★ Bands are computed in the visual (Format › Ages and categories › Group ages); the surplus of one side, median and mean ages and birth years are ★ too.
- Without Side, two measures face each other: that is a butterfly chart.
Going further: the use cases (generations, comparisons, indicators), the fields and settings reference, the basics shared by every Plume visual, the visual's page and support.