Forum Discussion
Monthly headcount based on hire date formula
That could be
=IF($D2<=E$1,"yes","no")
and drag it to other cells. If I understood your logic correctly, please check attached file.
- ZeelynnOct 29, 2020Copper ContributorHow would you do a formula to grab the employees that were hired and rehired on or before a certain but excluded the ones that were terminated before that date?
- SergeiBaklanOct 29, 2020Diamond Contributor
In general that's much more complex tax which is better to do with database or Excel tables whic imitates database. Tables could be
- departments: ID and name
-employees: ID, name, perhaps other static information like birthday
- employees history: date, employee ID, department ID (in case of change), within it hiring and termination dates
- calendar with each date for entire history
Above is simplified, could be bit more complex
After that Power Query itself or in combination with data model operations could generate desired reports.
Less reliable way is with formulas, but least you need to have termination date in your records.
- zrob94Feb 07, 2022Copper Contributor
SergeiBaklan Hi i have a smiliar question trying to get monthly headcount for a particular department i have start dates and leave dates
Similar data to the person below but also leave dates.
I dont know what countifs function to use to get the monthly data for example all employees at X department up until 31st January 2022.
- egspen2Oct 11, 2020Copper Contributor
SergeiBaklan Thanks - this makes sense to me and is what I was trying to do. However, when I copy this same formula into my document, I get return different values (for example, I get a no when you get a yes). Did you have to re-format the date or anything with the source file? See attached for my sheet simply updated for the formula you suggested - not sure why we get different answers.
- SergeiBaklanOct 11, 2020Diamond Contributor
You keep information about the hire dates as texts, not as dates. At the same in columns headers somewhere are dates, somewhere are texts.
I'd suggest to keep all dates as dates (which are actually numbers in Excel), not as texts. For that first convert Hire Date with Text to Columns into the dates
After that be sure you have no texts in columns headers, change all texts on dates
With that it shall work