Forum Discussion

LaBicicleta's avatar
LaBicicleta
Regular Visitor
5 years ago

Retained Employees with TenureDate table

Hi, I'm looking to beef up a report counting EmployeesAtDate and EmployeesAt1YearPrior with a retained employees since 1YearAgo column. So far my Excel PowerPivot PivotTable is:

 

Row LabelsEmployeesAtDateEmployeesAt1YearPrior

1/1/2019189 
2/1/2019199 
3/1/2019203 
4/1/2019207 
5/1/2019217 
6/1/2019225 
7/1/2019227 
8/1/2019237 
9/1/2019243 
10/1/2019247 
11/1/2019239 
12/1/2019234 
1/1/2020231189
2/1/2020235199
3/1/2020228203
4/1/2020227207
5/1/2020236217
6/1/2020233225
7/1/2020233227
8/1/2020221237
9/1/2020223243
10/1/2020215247
11/1/2020218239
12/1/2020213234
1/1/2021209231
2/1/2021200235
3/1/2021204228
4/1/2021201227
5/1/2021199236
6/1/2021185233
7/1/2021187233
8/1/2021194221

 

There's two pretty straightforward tables involved here.

tblCalendar = {"1/1/2019"..."8/1/2021"} - the first date of each month in the period of interest

qryEmployeeActiveTime = a set of rows made up of an employee ID and a date for every date they are active. For instance, if Alice was active from 1/1/2020 thru 1/3/2020, there would be the following rows in the table:

EmployeeTenureDate
Alice1/1/2020
Alice1/2/2020
Alice1/3/2020

 

In the PivotTable on the top, "EmployeesAtDate" is a count of all rows where TenureDate matches the tblCalendar[Date] of the row given. The "EmployeesAt1YearPrior" is a count of all rows where the TenureDate matches DATEADD(tblCalendar[Date],-1,YEAR) of the row given.

 

What I need to do for the retained employees is get a count of all employees who are active at the tblCalendar[Date] of the row given, who were also active at DATEADD(tblCalendar[Date],-1,YEAR). I'm throwing crap at the wall to see what sticks and not coming up with much. Any pointers?

2 Replies

    • LaBicicleta's avatar
      LaBicicleta
      Regular Visitor

      Hi amitchandak , thanks for reaching out!

       

      The issue is that we have a lot of rehires here, so there's multiple periods of tenure that need considered, I can't just grab the current "End Date" from the employee table if they're a rehire.

       

      However, what I can do is use PowerQuery to generate a table that would have one row for each employee-tenure period, a la:

       

      Row IDEmployee IDTenure_StartTenure_End
      1Alice3/1/20188/20/2019
      2Alice10/31/201912/31/2049
      3Bob7/1/202112/31/2049

       

      I can certainly try this out.

       

      I did try to pursue a solution with my existing two tables in the original post, and I came up with this English explanation of what I envision as the solution:

      1. Filter for all rows where the [TenureDate] is tblCalendar[Date] or DATEADD(tblCalendar[Date],-1,YEAR).
      2. Summarize this table and group by [Employee ID], counting [EmployeeID] instances as "TenuredInstancesOfInterest".
      3. Filter this resulting table for where count of the virtual table is 2.
      4. Count rows of this resulting-resulting table.

      My attempted solution was this:

       

       

       

       

       

      =COUNTROWS(
         FILTER(
            SUMMARIZE(
               FILTER(qryEmployeeActiveTime,
                  OR(
                     [TenureDate]=DATEADD(tblCalendar[Date],0,YEAR), 
                     [TenureDate]=DATEADD(tblCalendar[Date],-1,YEAR)
                  )
               ),
              [EmployeeID],
              "TenureInstancesOfInterest",COUNT([EmployeeID])
           ),
           [TenureInstancesOfInterest]=2
         )
      )