cancel
Showing results 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.

Frequent Visitor

Count Active Employees by time slicer month and year

Dear community,

I am struggling of counting the number of active employees by selecting different year and month.

The result that I am expecting is by selecting the time slicer month and year, it shows the actual number of employee of the month and year selected.

In result, we could also show a curve of evolution of number of employees by time.

Please kindly find the data sample in attachment.

I've tried the popular formula like below, However the result is always less than the real number.

Current Employees = CALCULATE(COUNTx(FILTER(Employee,Employee[Start Date]<=max('Date'[Date]) && (ISBLANK(Employee[End Date])

1 ACCEPTED SOLUTION
Community Support

You need a calendar table. There's no relationship between tables.

``Calendar = CALENDAR(MIN('Employee'[Start Date]),MAX('Employee'[End Date]))``

Create the following measure.

``Count = CALCULATE(COUNTROWS('Employee'),FILTER('Employee',[Start Date]<MIN('Calendar'[Date])&&([End Date]>MAX('Calendar'[Date])||[End Date]=BLANK())))``

The result is this. You can check more details from the attachment.

Best Regards,

Stephen Tao

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

2 REPLIES 2
Community Support

You need a calendar table. There's no relationship between tables.

``Calendar = CALENDAR(MIN('Employee'[Start Date]),MAX('Employee'[End Date]))``

Create the following measure.

``Count = CALCULATE(COUNTROWS('Employee'),FILTER('Employee',[Start Date]<MIN('Calendar'[Date])&&([End Date]>MAX('Calendar'[Date])||[End Date]=BLANK())))``

The result is this. You can check more details from the attachment.

Best Regards,

Stephen Tao

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

Super User

You'll need to include the employees who have an end date which is greater than the selected date (in context), not just the blank end date.

So that's adding an OR condition to the 2nd clause.

I think there are syntax problems with the current formula too.  Probably replace the calculate(countx  with COUNTROWS

Announcements

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

Power BI Monthly Update - April 2024

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

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors