Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

Calculate staff pool by age

Hi,

Source is a tabell with name, staff number, birthday and position.

for example:

fep_0-1599411235246.png

 

I would like to group them by position and age, but I want to see how this look in 3-5 years, when I know that employe retirement at the age of 70.

 

fep_1-1599411385124.png

 

Thanks

 

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@Anonymous - You could create an Age column like this:

Age = 
    VAR __Age = DATEDIFF([Date of Birth],TODAY(),YEAR)
RETURN
    SWITCH(TRUE(),
        __Age>=25 && __Age<30,"25-30",
        __Age>=30 && __Age<50,"30-50",
        __Age>=50 && __Age<70,"50-70"
    )

For 3 years in the future, it would be this:

Age = 
    VAR __Age = DATEDIFF([Date of Birth],DATE(YEAR(TODAY())+3,MONTH(TODAY()),DAY(TODAY())),YEAR)
RETURN
    SWITCH(TRUE(),
        __Age>=25 && __Age<30,"25-30",
        __Age>=30 && __Age<50,"30-50",
        __Age>=50 && __Age<70,"50-70"
    )


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , if you need to create a bucketing. You need to create age

 

Age column =

var _age = datediff ([date of birth],today(),year)

return

Switch( True(),

_age  < 25, " 0 -25",

_age  < 30, " 25 -30",

_age  < 50, " 30 -50",

_age  < 70, " 70 -70"

)

 

In case you need that is base on the selected date on page

 

Age measure = datediff ([date of birth],selectedvalue[date[date]) ,year)

 

Now you need have a bucket table with  limits and have one more measure with the name in the row context to handle the same

For that refer

https://www.daxpatterns.com/dynamic-segmentation/
https://www.daxpatterns.com/static-segmentation/
https://radacad.com/dynamic-banding-or-grouping-in-power-bi-using-dax-measures-choose-the-size-of-bins
https://www.credera.com/blog/technology-solutions/creating-aging-report-using-a-user-selected-date-in-power-bi/

 

https://www.poweredsolutions.co/2020/01/11/dax-vs-power-query-static-segmentation-in-power-bi-dax-power-query/
https://radacad.com/grouping-and-binning-step-towards-better-data-visualization

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Greg_Deckler
Community Champion
Community Champion

@Anonymous - You could create an Age column like this:

Age = 
    VAR __Age = DATEDIFF([Date of Birth],TODAY(),YEAR)
RETURN
    SWITCH(TRUE(),
        __Age>=25 && __Age<30,"25-30",
        __Age>=30 && __Age<50,"30-50",
        __Age>=50 && __Age<70,"50-70"
    )

For 3 years in the future, it would be this:

Age = 
    VAR __Age = DATEDIFF([Date of Birth],DATE(YEAR(TODAY())+3,MONTH(TODAY()),DAY(TODAY())),YEAR)
RETURN
    SWITCH(TRUE(),
        __Age>=25 && __Age<30,"25-30",
        __Age>=30 && __Age<50,"30-50",
        __Age>=50 && __Age<70,"50-70"
    )


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.