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
rush
Helper V
Helper V

How to work out total headcount per Month based the Date Employed

I would like to count the number of people we would have had in a Month for a particular Year.

 

I currently have a table called Staff with columns:

 

  • DateEmployed
  • FullName
  • TerminationDate
  • Team Member Status

 

The formula would count everyone that has a Team Member status of "Team Member" & it would stop counting when they have a status of "Ex-Team Member" which would relate back to the TerminationDate.

 

 

NB: My TerminationDate for my Team Members for some reason has a date of 1899/12/31

 

1 ACCEPTED SOLUTION
Phil_Seamark
Employee
Employee

Hi @rush

 

You could try this calculated table that might be close.  It counts a month for an employee if they start/end part way though a month.  I assumed this is what you were after.

 

New Table = 
var MinDate = FIRSTDATE('Table1'[DateEmployed])
var Result =  
SUMMARIZE(
    FILTER(
        CROSSJOIN(
            ADDCOLUMNS(Table1,"End Date",if([TerminationDate]=DATE(1899,12,31),TODAY(),[TerminationDate])),
            ADDCOLUMNS(
                CALENDAR(
                    MinDate,
                    TODAY()
                    ),
                    "Active Month",DATE(YEAR([Date]),MONTH([Date]),1)
                )
            )
            , [Date] >= [DateEmployed] 
            && [Date] <= [End Date])
        ,[Active Month],
        "Head Count" , COUNT(Table1[FullName])
        )


return Result

headcount.png


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

3 REPLIES 3
Phil_Seamark
Employee
Employee

Hi @rush

 

You could try this calculated table that might be close.  It counts a month for an employee if they start/end part way though a month.  I assumed this is what you were after.

 

New Table = 
var MinDate = FIRSTDATE('Table1'[DateEmployed])
var Result =  
SUMMARIZE(
    FILTER(
        CROSSJOIN(
            ADDCOLUMNS(Table1,"End Date",if([TerminationDate]=DATE(1899,12,31),TODAY(),[TerminationDate])),
            ADDCOLUMNS(
                CALENDAR(
                    MinDate,
                    TODAY()
                    ),
                    "Active Month",DATE(YEAR([Date]),MONTH([Date]),1)
                )
            )
            , [Date] >= [DateEmployed] 
            && [Date] <= [End Date])
        ,[Active Month],
        "Head Count" , COUNT(Table1[FullName])
        )


return Result

headcount.png


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

@Phil_Seamark Is it possible to add columns in that calculated table which can be used to create a relationship with other tables as I need to be able to slice the data of the headcount?

@Phil_Seamark Thank you very much. It works perfectly well.

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.