Need PowerPivot (DAX) measure to determine number of active employees at any point in time

Sbakker1

New Member
Joined
Aug 5, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
I'm able to create the calculation in Excel that returns the number of active employees for any given date. I'm hopeful that there is a way to do this dynamically in PowerPivot so I can return the accurate count regardless of filters.
The employee table contains the fields 'Hire Date', 'Employee Status', and 'Activity Date' amongst others. So to get the number of active employees for any date the formula would be :
Generic: Active Employees = COUNTIFS([Hire Date], <= Selected Date , [Employee Status] = "Active") + COUNTIFS([Hire Date], <= Selected Date , [Employee Status] = "Terminated", [Activity Date] >=Selected Date )

Actual formula:
=COUNTIFS(EmpData[[#All],[Hire Date]], "<="&R1, EmpData[[#All],[Employee Status]], "Active") + COUNTIFS(EmpData[[#All],[Hire Date]], "<="&R1, EmpData[[#All],[Employee Status Date]], ">="&R1, EmpData[[#All],[Employee Status]], "Terminated")

I've also used Sumproduct to get the same result.
Actual formula:
=SUMPRODUCT((EmpData[[#All],[Hire Date]]<=R1)*(EmpData[[#All],[Employee Status]]="Active")) + SUMPRODUCT((EmpData[[#All],[Hire Date]]<=R1)*(EmpData[[#All],[Employee Status]]="Terminiated")*(EmpData[[#All],[Employee Status Date]]>=R1))

To break that down, I want a count of the active employees that were hired on or before the selected date, plus the terminated employees that were hired before the comparison date, but not terminated until after the selected date. For the PowerPivot model there are two tables, 'Employee data' and 'Fiscal Calendar'. The selected date will be from the 'Fiscal Calendar'.
Any thoughts on how to create a measure that will yield the correct results in PowerPivot?

Let me know if you need more information or an example.
Thank you.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hi,

Could you show us some sample data (preferably using XL2BB ) accompanied by the correct answer (based on the sample data provided)
 
Upvote 0

Forum statistics

Threads
1,214,588
Messages
6,120,409
Members
448,959
Latest member
camelliaCase

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top