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.
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
Solved! Go to Solution.
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 ) )
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 ) )
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
108 | |
100 | |
78 | |
64 | |
58 |
User | Count |
---|---|
148 | |
111 | |
94 | |
84 | |
67 |