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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
PatLam0187
Frequent Visitor

Calculate Active Employees with only 1 Date Column

Hello,

 

I am trying to calculate for the total number of Active employees and YoY growth.

 

The challenge I am facing is that my data is not commonly arranged arranged as I am using just 1 date column.


The data is structured like this and is connected to a Date Dimension table called [DateDim]

 

Employee IDStatusBegin DateAction

1001

Active2022-06-20New Hire
1001

Active

2023-10-27Leave of Absence
1001Active2024-12-04Return to Work

1001

Terminated2025-01-13Termination
1001Active2022-06-05Rehire
1002Active2022-06-20New Hire
1003Active2025-02-10New Hire
1004Active2025-06-01New Hire
1005Active2022-05-20New Hire
1005Active2023-02-20Change in Position
1005Terminated2025-05-15Termination

 

Thank you

1 ACCEPTED SOLUTION

Hi @PatLam0187 ,

 

Thank you for the detailed explanation.

Based on sample data  I have implemented the logic accordingly and uploaded the PBIX file for your review. Kindly take a moment to review it and let us know your feedback.

If you're still facing any challenges, please feel free to reach out we'll be happy to assist you further.

Looking forward to your response.

 

Best regards,
LakshmiNarayana

View solution in original post

24 REPLIES 24
v-lgarikapat
Community Support
Community Support

Hi @PatLam0187 ,

Thanks for reaching out to the Microsoft fabric community forum.

@ryan_mayu ,

@SamsonTruong ,

Thanks for your prompt response

 

I have implemented the required logic and uploaded a sample PBIX file for your review. Kindly have a look and let me know if any adjustments or additional changes are needed.

Looking forward to your feedback.

 

 

If this post helped resolve your issue, please consider the Accepted Solution. This not only acknowledges the support provided but also helps other community members find relevant solutions more easily.

We appreciate your engagement and thank you for being an active part of the community.

Best regards,
LakshmiNarayana
.

Hello @v-lgarikapat, the update you had provided is working when the filter/date slicer is not selected if I select 2025 for example it will not include the 2022 record and will only count who are active beggining 2025. It should include the active 2022 record. Thank you so much!

Hi @PatLam0187 ,

 

Thank you for the follow-up question.
I have revised the measure and uploaded the updated PBIX file.

Kindly review it and let me know if any adjustments or additional changes are needed.

Looking forward to your feedback.

 

Best regards,
Lakshmi Narayana

 

 

Hello @v-lgarikapat ,

 

The solution needs one last fine tuning I think.

 

The terminated profile in May is still counted as Active when I add a month slicer or a week slicer.

 

Let's say someone is terminated May 5, 2025. That record should be counted as Active in June or May 6, 2025 onwards.

 

Thank you so much for your help!

Hi @PatLam0187 ,

 

Thanks for the follow-up question. Could you please try the modified measure below?

CumulativeActiveEmployees_v3 =
VAR SelectedDate =
MAX ( 'DateDim'[Date] )
RETURN
CALCULATE (
DISTINCTCOUNT ( 'EmployeeDetails'[Employee ID] ),
FILTER (
ADDCOLUMNS (
SUMMARIZE ( 'EmployeeDetails', 'EmployeeDetails'[Employee ID] ),
"@LatestStatus",
VAR LatestRecord =
CALCULATETABLE (
TOPN (
1,
FILTER (
'EmployeeDetails',
'EmployeeDetails'[Begin Date] <= SelectedDate
&& 'EmployeeDetails'[Employee ID] = EARLIER ( 'EmployeeDetails'[Employee ID] )
),
'EmployeeDetails'[Begin Date], DESC
)
)
RETURN
MAXX ( LatestRecord, 'EmployeeDetails'[Status] )
),
[@LatestStatus] = "Active"
)
)

 

If this post helped resolve your issue, please consider the Accepted Solution. This not only acknowledges the support provided but also helps other community members find relevant solutions more easily.

We appreciate your engagement and thank you for being an active part of the community.

Best regards,
LakshmiNarayana
.

 

 

Hello @v-lgarikapat ,

 

Thank you for the code but for some reason I'm getting an error:

 

EARLIER/EARLIEST refers to an earlier row context which doesn't exist.

 

Let me know if further modifications are needed.

 

Thank you

Hi @PatLam0187 ,

 

Thanks for the follow-up question.

I’ve modified the DAX logic and uploaded the PBIX file here for reference.

 

 

Source data 

vlgarikapat_0-1750755408684.png

 

Result 

vlgarikapat_1-1750755456162.png

 

If this post helped resolve your issue, please consider the Accepted Solution. This not only acknowledges the support provided but also helps other community members find relevant solutions more easily.

We appreciate your engagement and thank you for being an active part of the community.

Best regards,
LakshmiNarayana
.

 

Hello @v-lgarikapat ,

 

Thank you for your consistent reply, appreciate it a lot.

 

The DAX code is still counting individual records that were active "as of date".

 

What I actually need is all records that are active. For example if I filter as of March 01, 2025 to March 15, 2025, the total records should be 3: 1002, 1003, and 1005 as the strt date of of 1004 being active is June 01, 2025.  And if I then filter as of June 01, 2025 to June 15, 2025, I should only see 4, 1002, 1003, and 1004 because 1005 is terminated as of May 15, 2025.

 

PatLam0187_2-1750773026619.png

 

Thanks again

 

 

 

 

Hi @PatLam0187 ,

 

Thank you for the detailed explanation.

Based on your screenshot and guidance, I have implemented the logic accordingly and uploaded the PBIX file for your review. Kindly take a moment to review it and let us know your feedback.

If your issue has been resolved, please consider marking the most helpful reply as the accepted solution. This helps other community members who might encounter a similar issue to find answers more efficiently.

 

If you're still facing any challenges, please feel free to reach out we'll be happy to assist you further.

Looking forward to your response.

Best regards,
LakshmiNarayana

 

vlgarikapat_0-1751007611552.png

 

Hi @PatLam0187 ,

 

If your question has been answered, kindly mark the appropriate response as the Accepted Solution. This small step goes a long way in helping others with similar issues.

We appreciate your collaboration and support!

Best regards,
LakshmiNarayana

Hi @PatLam0187 ,

If your question has been answered, kindly mark the appropriate response as the Accepted Solution. This small step goes a long way in helping others with similar issues.

We appreciate your collaboration and support!

Best regards,
LakshmiNarayana

@v-lgarikapat , apologies for the delay I was away for a different project. The code did not work for me it still counted as of the date and the total of active profiles. I had modified my data source with the end date of each action. Please let me know if this is better and also note that I would also need a monthly progression of how many "actives" there are.

 

Again, thank you for your support.

 

New Source in next reply.

Employee No.Employment StatusBegin DateEnd DateAction TypeReason for Action
2205037Active2024-09-032025-03-24New HireNew Position
2205037Active2025-03-252025-03-30Leave of AbsenceSTD
2205037Active2025-03-312025-04-29Return from LeaveReturn From Leave
2205037Active2025-04-309999-12-31Change in PositionLateral
2205038Active2024-09-032024-12-28New HireNew Position
2205038Withdrawn2024-12-299999-12-31TerminationResignation
2205039Active2024-09-162025-04-29New HireNew Position
2205039Active2025-04-309999-12-31Change in PositionLateral
2205040Active2024-09-162025-02-21New HireNew Position
2205040Withdrawn2025-02-229999-12-31TerminationResignation
2205041Active2024-09-162025-01-22New HireNew Position
2205041Withdrawn2025-01-239999-12-31TerminationResignation
2205042Active2024-09-162025-04-29New HireNew Position
2205042Active2025-04-309999-12-31Change in PositionLateral
2205043Active2024-09-162025-04-29New HireNew Position
2205043Active2025-04-309999-12-31Change in PositionLateral
2205044Active2024-09-162025-02-17New HireNew Position
2205044Withdrawn2025-02-189999-12-31TerminationResignation
2205045Active2024-09-162025-04-29New HireNew Position
2205045Active2025-04-309999-12-31Change in PositionLateral
2205046Active2024-09-232025-02-10New HireNew Position
2205046Withdrawn2025-02-119999-12-31TerminationDismissal
2205047Active2024-09-232025-04-29New HireNew Position
2205047Active2025-04-309999-12-31Change in PositionLateral
2205048Active2024-09-232025-04-29New HireNew Position
2205048Active2025-04-309999-12-31Change in PositionLateral
2205049Active2024-09-232025-04-29New HireNew Position
2205049Active2025-04-309999-12-31Change in PositionLateral
2205050Active2024-09-232025-04-29New HireNew Position
2205050Active2025-04-309999-12-31Change in PositionLateral
2205051Active2024-09-232025-04-29New HireNew Position
2205051Active2025-04-309999-12-31Change in PositionLateral
2205052Active2024-09-232025-04-29New HireNew Position
2205052Active2025-04-309999-12-31Change in PositionLateral
2205053Active2024-09-162025-04-29New HireNew Position
2205053Active2025-04-309999-12-31Change in PositionLateral
2205054Active2024-09-302025-04-29New HireNew Position
2205054Active2025-04-309999-12-31Change in PositionLateral
2205055Active2024-10-142024-10-14New HireNew Position
2205055Active2024-10-152025-04-29Change in PositionLateral
2205055Active2025-04-309999-12-31Change in PositionLateral
2205056Active2024-10-142025-04-29New HireNew Position
2205056Active2025-04-309999-12-31Change in PositionLateral
2205057Active2024-11-112025-04-29New HireNew Position
2205057Active2025-04-309999-12-31Change in PositionLateral
2205058Active2024-10-212025-04-29New HireNew Position
2205058Active2025-04-309999-12-31Change in PositionLateral
2205059Active2024-10-212025-04-29New HireNew Position
2205059Active2025-04-309999-12-31Change in PositionLateral
2205060Active2024-10-212025-04-29New HireNew Position
2205060Active2025-04-309999-12-31Change in PositionLateral
2205061Active2024-10-212024-11-29New HireNew Position
2205061Withdrawn2024-11-309999-12-31TerminationResignation
2205062Active2024-10-212025-04-29New HireNew Position
2205062Active2025-04-309999-12-31Change in PositionLateral
2205063Active2024-10-212025-04-29New HireNew Position
2205063Active2025-04-309999-12-31Change in PositionLateral
2205064Active2024-11-042025-04-29New HireNew Position
2205064Active2025-04-309999-12-31Change in PositionLateral
2205065Active2024-11-042025-04-29New HireNew Position
2205065Active2025-04-309999-12-31Change in PositionLateral
2205066Active2024-11-112025-04-29New HireNew Position
2205066Active2025-04-309999-12-31Change in PositionLateral
2205067Active2024-11-112025-04-29New HireNew Position
2205067Active2025-04-302025-05-26Change in PositionLateral
2205067Active2025-05-279999-12-31Change in PositionPerm. Bulletin/Award
2205068Active2024-11-112025-04-29New HireNew Position
2205068Active2025-04-309999-12-31Change in PositionLateral
2205069Active2024-11-052025-04-29New HireNew Position
2205069Active2025-04-309999-12-31Change in PositionLateral

Hi @PatLam0187 ,

 

Thank you for the detailed explanation.

Based on sample data  I have implemented the logic accordingly and uploaded the PBIX file for your review. Kindly take a moment to review it and let us know your feedback.

If you're still facing any challenges, please feel free to reach out we'll be happy to assist you further.

Looking forward to your response.

 

Best regards,
LakshmiNarayana

@v-lgarikapat , This worked perfectly. Thank you!

Hi @PatLam0187 ,

You're very welcome! I'm glad it worked out perfectly

 

Best Regards,

Lakshmi.

Hi @PatLam0187 ,

 

I wanted to follow up and confirm whether you’ve had a chance to review the information we shared. If you have any questions or need further clarification, please don’t hesitate to reach out.

If you're still encountering any challenges, feel free to let us know we’d be glad to assist you further.

Looking forward to your response.

Best regards,
Lakshmi Narayana

Hi @PatLam0187 ,

As we haven't heard back from you, we are closing this thread. If you are still experiencing the issue, please feel free to create a new thread we’ll be happy to assist you further.

Thank you for your patience and support.

If you found our response helpful, please mark it as Accepted Solution so others with similar queries can find it easily.

 

Best Regards,

Lakshmi Narayana

Hi @PatLam0187 ,
Thank you for sharing the sample data. I’ll implement the logic based on this and share the sample PBIX file with you shortly.

Appreciate your patience and understanding.

 

Best Regards,

Lakshmi Narayana

 

 

ryan_mayu
Super User
Super User

@PatLam0187 

will 1001 and 1002 be counted as active for year 2023 and beyond?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.