Forum Discussion

Jorgast's avatar
Jorgast
Icon for Resolver II rankResolver II
7 years ago

Monthly Historical Headcount

Hi Everyone

 

I have a date table that is joined to an employee table via the hire date. What i am trying to find out is how many active employees i have for a given month based on a date slicer. How can i do that?

 

Here some sample date and output

ID NumberNameHire DateTermination DateStatus
1Iron Man2/1/201812/31/9999ACTIVE
2Capt America3/1/201812/31/9999ACTIVE
3Dr. Strange4/1/201812/31/9999ACTIVE
4Black Widow5/1/201812/31/9999ACTIVE
5Scarlett Witch6/1/201811/1/2018TERM
6Hawkeye7/1/201812/31/9999ACTIVE
7Thor8/1/201810/1/2018TERM
8Spiderman9/1/201812/31/9999ACTIVE
9Ant Man10/1/201812/31/9999ACTIVE

 

 

OUTPUT

MONTHHEADCOUNT
2/1/20181
3/1/20182
4/1/20183
5/1/20184
6/1/20185
7/1/20186
8/1/20187
9/1/20188
10/1/20188
11/1/20187
12/1/20187

 

2 Replies

  • Hi Jorgast

     

    What you're wanting is an "events in progress" measure.

     

    In your case, I would probably leave your data structure unchanged and use a measure like this:

     

    Headcount at end of period = 
    VAR MaxDate =
        MAX ( 'Date'[Date] )
    VAR TermDateFilter =
        DATESBETWEEN ( Employee[Termination Date], MaxDate, BLANK () ) // Termination Date >= MaxDate
    VAR HireDateFilter =
        DATESBETWEEN ( Employee[Hire Date], BLANK (), MaxDate ) // Hire Date <= MaxDate
    RETURN
        CALCULATE ( COUNTROWS ( Employee ), TermDateFilter, HireDateFilter )

    This measure gives you the Headcount as at the last day filtered (e.g. the last day of the month if filtered on month).

     

    Here is a sample model using this measure using the data you posted:

    OneDrive Link

     

    If you search for events in progress, there are various approaches out there including:

     Regards,

    Owen

    • Jorgast's avatar
      Jorgast
      Icon for Resolver II rankResolver II

      OwenAuger 

       

      I think i am missing something. I plugged in the measure, and renamed the Hire/Term fields to meet my needs. When i run the calculation it shows me the number of agents that were hired by the end of the month. I need to know  all the active agents in a given month and year.