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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
rdonohoe
Regular Visitor

Active Employees per Period

Hi, 

 

I have a table with employees showing start and end dates. I have a chart showing the number of employees who left and joined in a particular month. 

 

I would like to add another count; the number of employees employeed on the last day of the period (in my case month) 

 

It seems to me I need to write a measure that checks that start date is less than or equal to the begining of the current period and the end date is empty or greater than the current period. 

 

I would appreciate help with this.

 

Rob 

 

 

1 ACCEPTED SOLUTION
mattbrice
Solution Sage
Solution Sage

Assuming you have 'Year'/'Month' on rows/columns, perhaps something like this:

 

 

Employeed last day of Month =
VAR _lastDateOfPeriod =
    LASTDATE ( Calendar[Date] )
RETURN
    COUNTROWS (
        FILTER (
            EmployeeTable,
            VAR _hireDate = EmployeeTable[StartDate]
            VAR _termDate =
                IF ( ISBLANK ( EmployeeTable[EndDate] ), DATE ( 2099, 1, 1 ), EmployeeTable[EndDate] )
            RETURN
                _hireDate <= _lastDateOfPeriod
                && _termDate >= _lastDateOfPeriod
        )
    )

 

View solution in original post

1 REPLY 1
mattbrice
Solution Sage
Solution Sage

Assuming you have 'Year'/'Month' on rows/columns, perhaps something like this:

 

 

Employeed last day of Month =
VAR _lastDateOfPeriod =
    LASTDATE ( Calendar[Date] )
RETURN
    COUNTROWS (
        FILTER (
            EmployeeTable,
            VAR _hireDate = EmployeeTable[StartDate]
            VAR _termDate =
                IF ( ISBLANK ( EmployeeTable[EndDate] ), DATE ( 2099, 1, 1 ), EmployeeTable[EndDate] )
            RETURN
                _hireDate <= _lastDateOfPeriod
                && _termDate >= _lastDateOfPeriod
        )
    )

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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