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
Anonymous
Not applicable

Active Employees HR headcount dashboard

Hello,

 

I am trying to calculate the active employee's in the company between the dates i put in my date filter. I've got a master date table that I am using in the date filter. Below is the measure I am currently using but it keeps coming up with "blank":

active employees = CALCULATE(COUNT(Starters[Emp code]),FILTER('Starters - ETWeb','Starters - ETWeb'[Date hired] <= MAX('Date'[DATE]) && 'Starters - ETWeb'[Actual leaving date]> MIN('Date'[DATE])))
 
Can anyone help?
 
Thanks,
Alice
1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

If active employees refer to the ones who are working for this company between selected date the period.

For example, if i select date 2018/7/1~2019/4/17, then active employees should be hired before or at 2018/7/1, leave after 2019/4/17.

 

If my assumption is the same as your scenario,

 

Please create such relationship

2.png

create such measure

Measure = CALCULATE(COUNT('code table'[code]),FILTER(Sheet4,Sheet4[hired]<=MIN('calendar'[Date])&&Sheet4[leaving]>MAX('calendar'[Date])))

3.png

Best Regards

Maggie

View solution in original post

2 REPLIES 2
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

If active employees refer to the ones who are working for this company between selected date the period.

For example, if i select date 2018/7/1~2019/4/17, then active employees should be hired before or at 2018/7/1, leave after 2019/4/17.

 

If my assumption is the same as your scenario,

 

Please create such relationship

2.png

create such measure

Measure = CALCULATE(COUNT('code table'[code]),FILTER(Sheet4,Sheet4[hired]<=MIN('calendar'[Date])&&Sheet4[leaving]>MAX('calendar'[Date])))

3.png

Best Regards

Maggie

CheenuSing
Community Champion
Community Champion

Hi @Anonymous 

 

I am not sure if the following approach can work for you.

The approach assumes you have a CalendarTable.  My fact table is FactHR.  The two tables are linked on Date field in both tables.

 

1. Compute Continuing Employees

           

ContinuingEmployees =
VAR CurrentEmployees =
       CALCULATETABLE(
          DISTINCT('FactHR'[Employee GEID]),'FactHR')
VAR PreviousEmployees =
       CALCULATETABLE(
          DISTINCT('FactHR'[Employee GEID]) ,
               CALCULATETABLE( 'FactHR',
                  FILTER( ALL('MasterCalendar'),
                          'MasterCalendar'[Date] < MIN('MasterCalendar'[Date])
                     )     )  )
RETURN
CALCULATE(COUNTROWS(DISTINCT('FactHR'[Employee GEID])),
     INTERSECT(CurrentEmployees,PreviousEmployees)  )
 
This one creates the current table of Employee ID as of the selected month.
Then computes the table of employeeids before the selected month.
 
Similarly compute the new employees in a month.
 
2.  NewEmployees =
VAR CurrentEmployees =
    CALCULATETABLE(
       DISTINCT('FactHR'[Employee GEID]), 'FactHR')
VAR PreviousEmployees =
    CALCULATETABLE(
        DISTINCT('FactHR'[Employee GEID]) ,
            CALCULATETABLE('FactHR',
                FILTER( ALL('MasterCalendar'),
                        'MasterCalendar'[Date] < MIN('MasterCalendar'[Date])
                )  )   )
Return
CALCULATE(COUNTROWS(DISTINCT('FactHR'[Employee GEID])),
          EXCEPT(CurrentEmployees, PreviousEmployees))
 
3. PreviousMonthCount
PreviousMonthEmpCount = CALCULATE(COUNTROWS(DISTINCT('FactHR'[Employee GEID]))
                                 ,DATEADD('MasterCalendar'[Date],-1,month))
 
 
4. Left Employees
LeftEmployees = IF(ISBLANK(COUNTROWS(DISTINCT('FactHR'[Employee GEID]))),
                      BLANK(),
                        IF(not ISBLANK([PreviousMonthEmpCount]),
                     [PreviousMonthEmpCount] - [ContinuingEmployees])  )
 
4. Active as at end month
 
HeadCount = [PreviousMonthEmpCount] + [RevNewEmployees] - [RevLeftEmployees]
 
Cheers
 
CheenuSing
 
 
 
 
Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

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.

Top Solution Authors