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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Target
Helper I
Helper I

How to calculate the total employee count for each year based on Hiredate and terminationdate

In my data,i have hiredate and termination date columns,based on that i need to arrive the total employee count for each year

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Target ,

Thank you for @bhanu_gautam answer , and I have other suggestions for you:

Below is my Date table(indicate this customer activity time):

vxiandatmsft_0-1722929754340.png

Below is my hiredate and termination date table:

vxiandatmsft_1-1722929777278.png

You can create a new column to judge the customer whether work in company:

 

IsActive = 
VAR CurrentDate = 'Date'[Date]
RETURN
CALCULATE(
COUNTROWS('Table'),
FILTER(
'Table',
'Table'[hiredate] <= CurrentDate &&
(ISBLANK('Table'[termination date]) || 'Table'[termination date] >= CurrentDate)
)
)

 

vxiandatmsft_2-1722929828896.png

And then you can create a measure to calculate the number of the customer:

ActiveEmployees = 
    CALCULATE(
        COUNTROWS('Table'),
        FILTER(
            'Table',
            'Table'[hiredate] <= MAX('Date'[Date]) &&
            (ISBLANK('Table'[termination date]) || 'Table'[termination date] >= MIN('Date'[Date]))
        )
    )

The final output will be like this:

vxiandatmsft_0-1722930014072.png

Best Regards,

Xianda Tang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @Target ,

Thank you for @bhanu_gautam answer , and I have other suggestions for you:

Below is my Date table(indicate this customer activity time):

vxiandatmsft_0-1722929754340.png

Below is my hiredate and termination date table:

vxiandatmsft_1-1722929777278.png

You can create a new column to judge the customer whether work in company:

 

IsActive = 
VAR CurrentDate = 'Date'[Date]
RETURN
CALCULATE(
COUNTROWS('Table'),
FILTER(
'Table',
'Table'[hiredate] <= CurrentDate &&
(ISBLANK('Table'[termination date]) || 'Table'[termination date] >= CurrentDate)
)
)

 

vxiandatmsft_2-1722929828896.png

And then you can create a measure to calculate the number of the customer:

ActiveEmployees = 
    CALCULATE(
        COUNTROWS('Table'),
        FILTER(
            'Table',
            'Table'[hiredate] <= MAX('Date'[Date]) &&
            (ISBLANK('Table'[termination date]) || 'Table'[termination date] >= MIN('Date'[Date]))
        )
    )

The final output will be like this:

vxiandatmsft_0-1722930014072.png

Best Regards,

Xianda Tang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Target
Helper I
Helper I

Hi,

 IsActive =
VAR CurrentDate = 'DateTable'[Date]
Here DateTable[Date] is derived from calendarAuto fuction?



Yes, it is a date table




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






bhanu_gautam
Super User
Super User

@Target ,Add calculated columns to determine if an employee was active in a given year. You can do this by creating a column in your date table that checks if the date falls between the hire date and termination date.

 

IsActive =
VAR CurrentDate = 'DateTable'[Date]
RETURN
CALCULATE(
COUNTROWS('YourTable'),
FILTER(
'YourTable',
'YourTable'[hiredate] <= CurrentDate &&
(ISBLANK('YourTable'[terminationdate]) || 'YourTable'[terminationdate] >= CurrentDate)
)
)

 

 

Than create a measure for active employee

ActiveEmployees =
    CALCULATE(
        COUNTROWS('YourTable'),
        FILTER(
            'YourTable',
            'YourTable'[hiredate] <= MAX('DateTable'[Date]) &&
            (ISBLANK('YourTable'[terminationdate]) || 'YourTable'[terminationdate] >= MIN('DateTable'[Date]))
        )
    )



Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Target_0-1722579397235.png

It shows error

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.