
For this week’s challenge, we’re still in community month, so guest poster, Anna Clara Gatti, provided us with this challenge – to represent the spread of population in a pyramid. Anna provided 3 levels to the challenge, so I’m going to write this blog, building on each challenge.
Beginner Challenge
Defining the calculations
To start this we need to create some calculations. Firstly we have measures Male and Female which provide us with the population for each of the associated genders. But we need to ascertain the total population for each Country and Year so we can then calculate a % of total. So we need
Total Population
{FIXED [Country], [Year]: SUM([Male]) + SUM([Female])}
and from this we can then define
Male – % of Total Population
SUM([Male])/SUM([Total Population])
format this to a % with 1 dp
Female – % of Total Population
SUM([Female])/SUM([Total Population])
format this to a % with 1 dp
These are the core measures we want to plot, but we want to plot this against the Age. But the Age provided is ‘text’ and not a pure number. So to make life easier, we’re going to extract the number out
Age Axis
IF [Age] = ‘Less than 1 year’ THEN 0
ELSEIF [Age]= ‘100+ years’ THEN 100
ELSE INT(LEFT([Age],FIND([Age],’ ‘,1)-1)) END
Move this into the Dimensions section of the data pane (above the line ).
Now we can start to build the required viz.
Building the Pyramid
On a new sheet add Country to the Filter shelf and select Italy. Add Year to the Filter shelf. By default it will add as a green continuous pill. Just click OK to the filter dialog presented.

Then right click on the Year pill in the Filter shelf, and select discrete. Another filter selection dialog will appear. Select 2024.
Add Age Axis to Rows and change to be a continuous (green) pill. Add Male – % of Total Population to Columns, and then add Female – % of Total Population to Columns too.

Change the mark type on the All marks card to bar and reduce the size a bit. Add Measure Names to Colour and adjust accordingly.

Right click on the Male – % of Total Population axis and
- Fix the axis from 0 to 0.01
- Reverse the scale
- Change the axis title

Then edit the Female – % of Total Population axis and fix the scale from 0 to 0.01 and rename the axis title to give you a symmetrical display

Add the following fields to the Tooltip of the All marks card, and then update accordingly :
- Male
- Female
- Female – % of Total Population
- Male – % of Total Population
- Age
Finally tidy up the display by removing row & column dividers, hiding the Age Axis (right click > uncheck show header) and removing the row gridlines.

Building the KPI
On a new sheet add Total Population to Text. Revert back to the Pyramid sheet, and set the both the filters to also apply to new KPI sheet you’re creating.
Update the text to include the ‘Total Population’ label and adjust size of font and align middle centre. Change the mark type to shape and select a transparent shape (for details on how to do this refer to this blog). Set the sheet to Entire View then apply a grey background. Ensure the Tooltip doesn’t show.

Creating the dashboard
Add the Pyramid chart and the KPI chart to a dashboard. I used a vertical layout container to organise the ‘rows’ , and then placed horizontal containers within, so I had a ‘row’ to show the filter controls, and a ‘row’ to show the KPI and then a ‘row’ to display the chart.
In the ‘row’ showing the KPI I added a text object alongside and used the wingdings character set to display a square symbol which I could then just colour to represent the legend.

My beginner version of the viz is here.
Intermediate Challenge
Colouring the pyramid
For this challenge, I started by simply duplicating the Pyramid built for the Beginner challenge. I then created a new field
Age Bracket
IF [Age Axis] <=14 THEN ‘Young’ ELSEIF [Age Axis] >= 65 THEN ‘Elder’
ELSE ‘Active population’
END
and added this to the Detail shelf of the All marks card. I then added this to be on the Colour shelf as well as Measure Names by updating the symbol to the left of the pill

Adjust the colours on the colour legend accordingly, and then update the Tooltip to include a reference to the Age Bracket.

Building the dashboard
Duplicate the original dashboard you built, then swap the pyramid chart by clicking on the Pyramid chart object in the dashboard. Then on the left hand side in the dashboard pane, click on the 2nd pyramid sheet, and click the ‘swap’ icon to replace the chart..

Remove the title that’s automatically added. Then update the legend text box.
My Intermediate version is here.
Advanced Challenge
Defining the additional fields
For this challenge, we’re going to need a lot more fields, including the following parameters
Country 1
string parameter, that is a list, and is populated from the Country field when the workbook is opened. Defaulted to Italy.

Country 2
As above but defaulted to Austria
Year 1
integer parameter, that is a list that is populated from the Year field when the workbook is opened. Defaulted to 2024 that is formatted to display as a number with 0 dp and no thousands separator.

Year 2
As above, also defaulted to 2024.
With these parameters, we also need to redefine the the total population values
Total Pop – Year & Country 1
IF [Year] = [Year 1] and [Country] = [Country 1] THEN [Total Population] END
Total Pop – Year & Country 2
IF [Year] = [Year 2] and [Country] = [Country 2] THEN [Total Population] END
and we also need to capture the male and female populations for these parameters
Male Pop – Year & Country 1
[Year] = [Year 1] AND [Country] = [Country 1] THEN [Male] END
Male Pop – Year & Country 2
[Year] = [Year 2] AND [Country] = [Country 2] THEN [Male] END
Female Pop – Year & Country 1
[Year] = [Year 1] AND [Country] = [Country 1] THEN [Female] END
Female Pop – Year & Country 2
[Year] = [Year 2] AND [Country] = [Country 2] THEN [Female] END
and then in turn, we redefine the % of total calculations
Male – % of Total 1
SUM([Male Pop – Year & Country 1])/ SUM([Total Pop – Year & Country 1])
Male – % of Total 2
SUM([Male Pop – Year & Country 2])/ SUM([Total Pop – Year & Country 2])
Female – % of Total 1
SUM([Female Pop – Year & Country 1])/ SUM([Total Pop – Year & Country 1])
Female – % of Total 2
SUM([Female Pop – Year & Country 2])/ SUM([Total Pop – Year & Country 2])
Set all the % of total calcs to be % with 1 dp.
Building the Pyramid
Once again start by duplicating the pyramid chart sheet built for the intermediate solution
Drag Male – % of Total 1 and drop it directly onto the existing Male = % of Total Population pill on the Columns shelf, so it basically replaces it.

Repeat the process by dragging Female – % of Total 1 and dropping it directly over Female – % of Total Population. Adjust the colours if required.
Remove the Country and Year field from the Filter shelf and show the 4 parameters.

Drag Male – % of Total 2 and add to Columns between the two existing pills.
On the Male – % of Total 2 marks card, change the mark type to Line , remove Measure Names from Colour and move Age Bracket to Tooltip. Change the colour to dark grey/black.

Make the % of total male pills dual axis and synchronise the axis.

Repeat the process by adding Female – % of Total 2 to Columns to the right hand side of the existing Female field, adjusting the mark type and colouring and making dual axis.

Right click on the top axis and uncheck show header to hide them. Then right click on the Male – % of Total 1 axis at the bottom, as as before, fix the axis from 0 to 0.01, reverse the axis, and update the title. Repeat for the Female axis (though don’t reverse).

On the All marks card, make sure all the following fields exist on the tooltip, then adjust the tooltip as required, referencing the parameters as well.
- Male Pop – Year & Country 1
- Male Pop – Year & Country 2
- Female Pop – Year & Country 1
- Female Pop – Year & Country 2
- Male – % of Total 1
- Male – % of Total 2
- Female – % of Total 1
- Female – % of Total 2
- Age
- Age Bracket
Building the KPI cards
Duplicate the original KPI card
Drag Total Pop – Year & Country 1 directly onto the existing Total Population field. Then add the Country 1 and Year 1 parameters to the Label shelf, and update the text as required. Remove the fields from the Filter shelf.

Repeat this process again but add the appropriate ‘2’ versions of the fields to create the 2nd KPI card.

Building the dashboard
Once again, duplicate the dashboard and swap the pyramid charts. Replace the filter controls (if still present) with a row of parameter controls.
Swap/add the KPI sheets, and add an additional Text object. Update the text to display the ‘legends’ as required.
I chose to add navigation buttons to my dashboard to move between the 3 versions of the challenge.

My advanced version is published here.
Phew! a lot going on here it seems. Hope you managed it all!
Happy vizzin’!
Donna




















































