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
jcastr02
Post Prodigy
Post Prodigy

# of People Employed with specific tenure

Hello I have a running list of employees with their names, Employee ID, Hire Date and Term Date.  List would continously grow as we hire employees.   I am trying to find a way to know on a given date how many people are active in the company with specific tenure (essentially removing team members with term dates on them).  Example on September 1st, we had 50 people that were of had a tenure of 31-37 days, 15 of a tenure of 61-67 days, etc.  Below see example of my data & desired results.  (Below are not true values are just made up data)

 

Below example of my data:

Employee NameEmployee IDHire DateTerm Date
Coto, Chris1237/23/2018 
Peyton, MeLisa4561/5/1990 
Contreras, Michelle78912/28/1995 
Belvin, Debra11229/13/1999 
Rivers, Carol14558/30/1999 
Hepp, Brenda17881/29/1997 
Monroe, Natalie212111/8/2013 
Hubbard, Tia 24545/23/20225/23/2022
Gloria, Rachel27875/30/20226/10/2022
Bentz-Bailey, Mackenzie312012/27/20213/16/2022
Burnes, Mayrn34538/9/20213/4/2022
Bademi, Mercedes378612/27/20213/16/2022
Wolfer, Adrian41199/6/20213/24/2022
Medina, Karla44521/3/20223/31/2022
Billig, Dana47854/18/20224/25/2022
Mitchell, Taylor51182/28/20225/4/2022
Barriga, Kyra54513/7/20224/11/2022
Doughty, Justin57843/7/20223/11/2022
Salazar, Idan61173/7/20223/11/2022
Peterson, Brianna64503/7/20223/7/2022
Vera, Amanda67833/7/20223/7/2022
Gutierrez, Rocio71164/18/20225/16/2022
Mcgee, Michelle 74493/28/20226/21/2022
Thornton, Mateen77822/7/20223/7/2022
Miller, Joanne81153/21/20223/30/2022
Russell, Mackenzie84483/14/20223/14/2022

 

Desired Result

 # of People Employed Tenure Days 31-37# of People Employed Tenure Days 61-67# of People Employed Tenure Days 91-97# of People Employed Tenure Days 181-187
9/1/202250151214
9/2/202250151214
9/3/202250151214
9/4/202250151214
9/5/202250151214
9/6/202250151214
9/7/202250151214
9/8/202245121820
9/9/202245121820
9/10/202245121820
9/11/202245121820
9/12/202245121820
9/13/202245121820
9/14/202245121820
9/15/202245121820
9/16/202225161710
9/17/202225161710
9/18/202225161710
9/19/202225161710
9/20/202225161710
9/21/202225161710
9/22/202225161710
9/23/2022105104
9/24/2022105104
9/25/2022105104
9/26/2022105104
2 ACCEPTED SOLUTIONS
jdbuchanan71
Super User
Super User

@jcastr02 

Interesting one, I think I got it to work.  I have a Dates table and a Tenure table along with the employee table.

Here is the measure I ended up with:

 

Active Employee Count = 
VAR _MinDate = MIN ( Dates[Date] )
VAR _MaxDate = MAX ( Dates[Date] )
VAR _MinDays = MIN ( Tenure[Start] )
VAR _MaxDays = MAX ( Tenure[End] )
VAR _Employees = 
    FILTER ( 
        ALLSELECTED ( Employees[Employee ID], Employees[Hire Date], Employees[Term Date] ), 
        Employees[Hire Date] <= _MaxDate && 
        ( Employees[Term Date] >= _MinDate || ISBLANK ( Employees[Term Date] ) ) 
    )
VAR _EmployeesWithDays = 
    ADDCOLUMNS ( _Employees, "@Days", _MaxDate - Employees[Hire Date] )
VAR _EmployeesByDays = 
    FILTER ( _EmployeesWithDays, [@Days] >= _MinDays && [@Days] <= _MaxDays )
RETURN 
    COUNTROWS ( _EmployeesByDays )

 

jdbuchanan71_0-1666192406741.png

You would need to modify the day ranges on the tenure table to match what you are looking for.  I have attached my sample file for you to look at.

 

 

 

View solution in original post

We can include the location in the ALLSELECTED like this:

Active Employee Count = 
VAR _MinDate = MIN ( Dates[Date] )
VAR _MaxDate = MAX ( Dates[Date] )
VAR _MinDays = MIN ( Tenure[Start] )
VAR _MaxDays = MAX ( Tenure[End] )
VAR _Employees = 
    FILTER (
        ALLSELECTED ( Employees[Employee ID], Employees[Hire Date], Employees[Term Date], Employees[Location] ), 
        Employees[Hire Date] <= _MaxDate && 
        Employees[Term Date] >= _MinDate || ISBLANK ( Employees[Term Date] ) 
    )
VAR _EmployeesWithDays = 
    ADDCOLUMNS ( _Employees, "@Days", _MaxDate - Employees[Hire Date] )
VAR _EmployeesByDays = 
    FILTER ( _EmployeesWithDays, [@Days] >= _MinDays && [@Days] <= _MaxDays )
RETURN 
    COUNTROWS ( _EmployeesByDays )

View solution in original post

3 REPLIES 3
jcastr02
Post Prodigy
Post Prodigy

@jdbuchanan71  You are Amazing - you have no idea how long it was taking me to figure out a solution!  I forgot to mention I have a column for "location" on the employee table which when I try to add a filter on the page, the #'s do not change.  Do you know how I could remedy that?  Your guidance is greatly appreciated.  See below two examples.

miami.pnglexington.png

We can include the location in the ALLSELECTED like this:

Active Employee Count = 
VAR _MinDate = MIN ( Dates[Date] )
VAR _MaxDate = MAX ( Dates[Date] )
VAR _MinDays = MIN ( Tenure[Start] )
VAR _MaxDays = MAX ( Tenure[End] )
VAR _Employees = 
    FILTER (
        ALLSELECTED ( Employees[Employee ID], Employees[Hire Date], Employees[Term Date], Employees[Location] ), 
        Employees[Hire Date] <= _MaxDate && 
        Employees[Term Date] >= _MinDate || ISBLANK ( Employees[Term Date] ) 
    )
VAR _EmployeesWithDays = 
    ADDCOLUMNS ( _Employees, "@Days", _MaxDate - Employees[Hire Date] )
VAR _EmployeesByDays = 
    FILTER ( _EmployeesWithDays, [@Days] >= _MinDays && [@Days] <= _MaxDays )
RETURN 
    COUNTROWS ( _EmployeesByDays )
jdbuchanan71
Super User
Super User

@jcastr02 

Interesting one, I think I got it to work.  I have a Dates table and a Tenure table along with the employee table.

Here is the measure I ended up with:

 

Active Employee Count = 
VAR _MinDate = MIN ( Dates[Date] )
VAR _MaxDate = MAX ( Dates[Date] )
VAR _MinDays = MIN ( Tenure[Start] )
VAR _MaxDays = MAX ( Tenure[End] )
VAR _Employees = 
    FILTER ( 
        ALLSELECTED ( Employees[Employee ID], Employees[Hire Date], Employees[Term Date] ), 
        Employees[Hire Date] <= _MaxDate && 
        ( Employees[Term Date] >= _MinDate || ISBLANK ( Employees[Term Date] ) ) 
    )
VAR _EmployeesWithDays = 
    ADDCOLUMNS ( _Employees, "@Days", _MaxDate - Employees[Hire Date] )
VAR _EmployeesByDays = 
    FILTER ( _EmployeesWithDays, [@Days] >= _MinDays && [@Days] <= _MaxDays )
RETURN 
    COUNTROWS ( _EmployeesByDays )

 

jdbuchanan71_0-1666192406741.png

You would need to modify the day ranges on the tenure table to match what you are looking for.  I have attached my sample file for you to look at.

 

 

 

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.