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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Complex age binning help required

 Hi,

 

Wondering if the community could help solve a way to do this.

 

I have a requirement to show a vis that will bin a count of staff into age groups (<16, 16-25, 25-35, 35-45, 45-55, 55-65, >65). Using normal binning technique I would apply a calculated column that would calculate the bin based on age and then plot count of staff against the bin attribute.

 

The requirements that are making this one a bit trickier is that I have to show a count of staff employed this year against a count of staff employed during the same period last year. This will mean that staff who are employed this year will be a year younger last year and they may fall into a different bin. I can't use the normal method of creating a calculated column as this is only calculated on load so the normal bin category would be fixed. I can't create a second column for the previous year bin as I need to show both counts on the same vis.

 

I've included some exemplar data below to assist if anyone can help with this.

 

Employee
StaffIDNameDOB
1Elnora Harland22/8/1965
2Talbot Spence4/2/1991
3Norene Johnson10/5/1984
4Parris Wolfe25/7/1954
5Joanna Honeysett16/9/1993
6Nik Tollemache16/10/1985
7Zeke Thorne13/1/1974

 

 

EmploymentHistory
StaffIDRoleIDDateStartDateEnd
1900110/01/200215/06/2009
1900216/06/20092/12/2015
190033/12/2015 
2900116/06/200912/04/2018
3900115/12/2018 
4900512/06/201612/08/2016
4900613/08/201613/11/2016
4900514/11/2016 
5900602/07/201011/08/2016
5900614/11/2016 
6900701/02/201531/05/2018
7900824/01/201831/07/2018

 

Anyone have an idea on how to do this?

 

2 REPLIES 2
v-yulgu-msft
Employee
Employee

Hi @Anonymous,

 

It's not very clear about the requirement.

 

Does age refers to the age of a staff which is the datediff between current year and DOB, or refers to the time a staff has been employed unitll now which is the datediff between DateStart and DateEnd?

 

Can you illustarte "This will mean that staff who are employed this year will be a year younger last year and they may fall into a different bin." with examples?

 

What is the desired result based on above sample data? Please provide more detailed description.

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thanks for the reply @v-yulgu-msft.

 

Age is DATEDIF from today.

 

If I were to work this out manually into a table I'd get the following:

 

StaffIDNameDOBAge CurrentAge Last YearBin This YearBin Last YearEmployed This YearEmployed Last Year
1Elnora Harland22/08/1965535245-5545-5511
2Talbot Spence04/02/1991282725-3525-3501
3Norene Johnson10/05/1984343325-3525-3510
4Parris Wolfe25/07/1954646355-6555-6511
5Joanna Honeysett16/09/1993252425-3515-2511
6Nik Tollemache16/10/1985333225-3525-3501
7Zeke Thorne13/01/1974454445-5535-4501

 

You can see how StaffID 5 and 7 fall into a different age bin when we count at the same time last year.

Also you'll notice that StaffID 3 is onlly counted this year as they weren't employed last year and StaffIDs 2, 6 and 7 aren't counted this year as they are no longer employed but were last year.

 

Following that through I should be able to get an answer table as shown below.

 

BinThis YearLast Year
<1500
15-2501
25-3522
35-4501
45-5511
55-6511
>6500

 

Hope this helps explain things a bit furhter.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.