The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Based on a table of employee records, including their birth dates and contract info, I need to create a population piramid. But there's an added challenge: the piramid needs to be sliceable to user-selected years. In other words, I want to show today's population piramid, but also the population piramid of, say, 2021 when my user selects that year.
Here's what I have in place:
What I want:
What I'm using as basis for the population piramid:
What I tried first:
What I've changed now:
But when I tried to use these in the bar chart, it stopped at the AgeBracket. Bar chart does not accept a measure as Y axis field.
So now I'm stumped. Using columns gets me what I want, but cannot be based on slicer value. Using measures can, but cannot be used in the bar chart axis.
How can I achieve what I want? Where is my thinking going wrong?
Solved! Go to Solution.
Hi @FlorisMK
Click here to download a solution from onedrive
Please click the thumbs up because I have spent a lot of time on this to try help you.
Then click accept solution if it works.
You can accept more than one solution.
How it works ....
Build detached tables with no relationships
This is the calendar table (first few records)
This is the age band table
Ths is your employee table
Add a slicer using the calendar year with single slection
User a measure to get the age using the start of the slicer year
Age =
DATEDIFF(
MIN(Employees[DOB]), MIN('Calendar'[Date]), YEAR)
Count the number of employees in the band
Employess in band =
var bandstart = MIN('Age bands'[Start])
var bandend = MIN('Age bands'[End])
RETURN
SUMX(Employees, IF( [Age] >= bandstart && [Age] <= bandend,1) )
Draw your graph
test the graph
Click here to download a solution from onedrive
This version has the gender split.
Please click thumbs up and accept solution
Click here to download solution from Onedrive
Hi @speedramps , thanks a bundle! This is great. I've combined it with comparing the selected date to the contract dates to decide what value to sum, and now I have a working solution! I'll take a look at your gender solution as well, but this deserves an Accept as Solution already.
This version has the gender split.
Please click thumbs up and accept solution
Click here to download solution from Onedrive
Hi @FlorisMK
Click here to download a solution from onedrive
Please click the thumbs up because I have spent a lot of time on this to try help you.
Then click accept solution if it works.
You can accept more than one solution.
How it works ....
Build detached tables with no relationships
This is the calendar table (first few records)
This is the age band table
Ths is your employee table
Add a slicer using the calendar year with single slection
User a measure to get the age using the start of the slicer year
Age =
DATEDIFF(
MIN(Employees[DOB]), MIN('Calendar'[Date]), YEAR)
Count the number of employees in the band
Employess in band =
var bandstart = MIN('Age bands'[Start])
var bandend = MIN('Age bands'[End])
RETURN
SUMX(Employees, IF( [Age] >= bandstart && [Age] <= bandend,1) )
Draw your graph
test the graph
Click here to download a solution from onedrive
User | Count |
---|---|
77 | |
76 | |
36 | |
32 | |
29 |
User | Count |
---|---|
93 | |
79 | |
57 | |
48 | |
48 |