Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. 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
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 9 | |
| 6 | |
| 3 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 23 | |
| 14 | |
| 10 | |
| 6 | |
| 5 |