Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
I'm trying to do some age analysis for a group of people and created an age column in Power Query based on the date of birth, but the ages are static based on today's date and I need them to be dynamic based on my date table. For instance, if the user is slicing to see the 2022 population I need the ages to represent each person's age in 2022, not their current age.
How can I determine the age dynamically so that I can use it for calculations like average age, min age, and max age, and also do an age distribution? My date of birth is located in my people[dob] column and the date is Date[Date].
Thank you!
Solved! Go to Solution.
@bonitatem Well, you could do something like this:
Count of Age Band =
VAR __Start = MAX( 'Age_Band'[Start] )
VAR __End = MAX( 'Age_Band'[End] )
VAR __Table = ADDCOLUMNS( 'people', "__Age", [Dynamic Age Measure] )
VAR __Result = COUNTROWS( FILTER( __Table, [__Age] >= __Start && [__Age] <= __End ) )
RETURN
__Result
Thanks for the reply from @Greg_Deckler , please allow me to provide another insight:
Hi @bonitatem ,
Here are the steps you can follow:
1. Create measure.
age distribution =
MAXX(
FILTER(ALL('Age_Band'),
[Dynamic Age Measure] >= 'Age_Band'[Start]&&[Dynamic Age Measure]<='Age_Band'[End]),[Age Band])
2. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
This works great for my measures - but how could I use this to do an age distribution? Currently I created a table to define my age bands and then I'm using a measure with TREATAS to create the distribution.
@bonitatem Well, you could do something like this:
Count of Age Band =
VAR __Start = MAX( 'Age_Band'[Start] )
VAR __End = MAX( 'Age_Band'[End] )
VAR __Table = ADDCOLUMNS( 'people', "__Age", [Dynamic Age Measure] )
VAR __Result = COUNTROWS( FILTER( __Table, [__Age] >= __Start && [__Age] <= __End ) )
RETURN
__Result
@bonitatem So like:
Dynamic Age Measure =
VAR __MaxDate = MAX( 'Dates'[Date] )
VAR __BD = MAX( 'People'[dob] )
VAR __Result = YEAR( __MaxDate ) - YEAR( __BD )
RETURN
__Result
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
10 | |
10 | |
9 | |
9 |
User | Count |
---|---|
20 | |
13 | |
12 | |
11 | |
8 |