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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
LaBicicleta
Regular Visitor

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 2
amitchandak
Super User
Super User

@LaBicicleta , What is you source data, where we can see Alice's start and end date.

 

If you have a start and end date. Refer to the file attached, which can help

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

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
   )
)

 

 

 

 

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

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