Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
HRAnalyst
New Member

Headcount with only Start Dates and End Dates

I am a new user of PowerBI but other threads do not seem to assist with my exact searches.

 

I have an overall employee data set that splits our organisation by Org, Department, Teams, Job Level etc - I then have start dates and end dates for all employees. Similar to below:

 

Employee NameOrganisationDepartmentTeamJob LevelJob TitleStart DateEnd Date
Bob SmithDoodlesMarketingSocial Media4Lead Social Media Organiser08/02/2022 
Clare SmithDoodlesMarketingSocial Media5Assistant Social Media Organiser01/03/202203/02/2022

 

I am trying to run a power query from our HR system so that each month I can report on our current headcount. All posts that I have come across so far show only reports which already have a headcount report that is being generated - would anyone be able to assist?

I've tried a few calculations from other posts which do not seem to return anything when I start putting the measure into visuals - I have a full date table in my PowerBI which I have tried methods of both linked and unlinked to the data set and it still returns blank. Any assistance would be great.

 

Thanks

6 REPLIES 6
HRAnalyst
New Member

Current Employees =
CALCULATE(COUNTX
FILTER'Employee Information','Employee Information'[Start Date]<=MAX(Dates[Date] )
&& (ISBLANK('Employee Information'[Last Day of Employment] )
|| 'Employee Information'[Last Day of Employment]>MAX(Dates[Date] ) ) ),
('Employee Information'[First Name] ) ),
CROSSFILTER('Employee Information'[Start Date],Dates[Date],None))

I ended up using the above which seemed to have done the job - thanks for the help below to get to this! 
ERD
Super User
Super User

Hi @HRAnalyst ,

You can use this measure:

Measure =
CALCULATE (
    COUNTROWS ( 'Table' ),
    'Table'[Start Date] <= MAX ( 'Date'[Date] ),
    'Table'[End Date] >= MIN ( 'Date'[Date] )
        || ISBLANK ( 'Table'[End Date] )
)

I assume you have a Date table not connected to the Data table.

ERD_0-1690393448282.png

 

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

hello @ERD its a smaller measure but it doesnt count it correctly on the month they left , so if you select march 2022 you will have 2 headcount instead of one 

annonymous1999_0-1690441200219.png

 

annonymous1999_1-1690441214065.png

 



So you don't want to count the month they left? Because from your first screenshot I see 3 people, as one of them was working 2 days in March.

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

eliasayyy
Super User
Super User

im not sure but lets say you have a calendar table and just start date and end date 

annonymous1999_0-1690382503289.png

create the emasure

headcount = 
VAR _r = 
SUMMARIZE(
    'Table',
    'Table'[Employee Name],
    "left?",
    IF(
    MAX('Table'[End Date]) <> BLANK() &&
    MONTH(MAX('CALENDAR'[Date])) >= MONTH(MAX('Table'[End Date]))
    , "Yes" , "No"),
    "started?",
    IF(
    MONTH(MAX('Table'[Start Date])) <= MONTH(MAX('CALENDAR'[Date]))
    , "Yes" , "No")
)
VAR _t = ADDCOLUMNS(_r,"Cond" , IF( [left?] = "No" && [started?] = "Yes" , 1,0))
return
COUNTROWS(FILTER(_t, [Cond] = 1))


end result

adc0dd1a-c096-4baa-bf81-106a7736b5b4.gif

 

yyzheng12
Helper I
Helper I

What does your table diagram look like? It all depends on your data structure.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.