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
Vanivanivani
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.

https://drive.google.com/file/d/12tJdT2qCtC7wsRC70_VAkXKf1vWXSn8Z/view?usp=sharing

 

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
v-stephen-msft
Community Support
Community Support

Hi @Vanivanivani ,

 

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

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

4.png

3.png

 

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.

5.png

 

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.

View solution in original post

2 REPLIES 2
v-stephen-msft
Community Support
Community Support

Hi @Vanivanivani ,

 

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

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

4.png

3.png

 

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.

5.png

 

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.

HotChilli
Super User
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

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.