Calculate the headcount at the end of each month based on the start/leave dates, split by employee type and country.

maxim642

Board Regular
Joined
Feb 4, 2021
Messages
91
Office Version
  1. 365
Platform
  1. MacOS
Dummy data is provided below. In the tables to the right of the dummy data (South Africa, Canada & Brazil), I'd like to calculate the headcount at the end of each month for the country, split by employee type. The headcount determiners will be the START DATE & LEAVE DATE columns.

If someone joined on the last/first day of the month, they should be counted for that reporting month (depending on the year they joined.

If the LEAVE DATE is blank or contains a future date (relative to the reporting month), the person is still employed and should be counted provided they started before the end of the reporting month.

If the START DATE is after the reporting month, the person should not be counted.

An example would be, Joe Bloggs started on 3rd March 2022 and left on 19th June 2022. They would not be included in the headcount for Jan, Feb, but would be in Mar, Apr, May & Jun.

Master Headcount - May - Dashboard.xlsx
ABCDEFGHIJKLMNOPQRSTU
1Full NameContract TypeSexStart DateLeave DateDepartmentReporting CountrySouth Africa
2Joe Bloggs1ContractorMale1/10/22TechnicalSouth AfricaContract TypeJan-22Feb-22Mar-22Apr-22May-22Jun-22Jul-22Aug-22Sep-22Oct-22Nov-22Dec-22
3Joe Bloggs2Perm, localMale1/17/223/18/22CEO’s OfficeSouth AfricaContractor
4Joe Bloggs3Perm, localFemale2/14/224/15/22CEO’s OfficeSouth AfricaPerm, local
5Joe Bloggs4FTCMale2/28/224/29/22LegalSouth AfricaFTC
6Joe Bloggs5FTCFemale3/1/224/30/22LegalSouth AfricaExpat
7Joe Bloggs6FTCFemale3/7/225/6/22LegalSouth Africa
8Joe Bloggs7FTCMale3/11/225/10/22LegalSouth Africa
9Joe Bloggs8FTCFemale3/15/225/14/22LegalSouth Africa
10Joe Bloggs9FTCFemale3/22/22LegalSouth AfricaCanada
11Joe Bloggs10Perm, localMale4/25/22TechnicalSouth AfricaContract TypeJan-22Feb-22Mar-22Apr-22May-22Jun-22Jul-22Aug-22Sep-22Oct-22Nov-22Dec-22
12Joe Bloggs11Perm, localMale5/1/22TechnicalSouth AfricaContractor
13Joe Bloggs12Perm, localFemale5/1/22HRSouth AfricaPerm, local
14Joe Bloggs13Perm, localMale5/1/225/26/22SecuritySouth AfricaFTC
15Joe Bloggs14Perm, localMale5/9/226/3/22TechnicalSouth AfricaExpat
16Joe Bloggs15Perm, localFemale5/16/226/10/22TechnicalSouth Africa
17Joe Bloggs16Perm, localMale5/23/226/17/22TechnicalSouth Africa
18Joe Bloggs17Perm, localMale5/23/226/17/22TechnicalSouth Africa
19Joe Bloggs18Perm, localMale5/25/226/19/22TechnicalSouth AfricaBrazil
20Joe Bloggs19Perm, localMale5/20/226/14/22SecuritySouth AfricaContract TypeJan-22Feb-22Mar-22Apr-22May-22Jun-22Jul-22Aug-22Sep-22Oct-22Nov-22Dec-22
21Joe Bloggs20Perm, localMale5/24/226/18/22TechnicalSouth AfricaContractor
22Joe Bloggs21Perm, localMale6/1/22TechnicalSouth AfricaPerm, local
23Joe Bloggs22Perm, localMale6/1/22TechnicalSouth AfricaFTC
24Joe Bloggs23Perm, localMale6/1/22TechnicalSouth AfricaExpat
25Joe Bloggs24Perm, localMale6/1/22TechnicalSouth Africa
26Joe Bloggs25Perm, localMale6/1/22TechnicalSouth Africa
27Joe Bloggs26Perm, localMale6/1/22TechnicalSouth Africa
28Joe Bloggs27Perm, localMale6/1/22Procurement South Africa
29Joe Bloggs28Perm, localFemale6/6/22ITSouth Africa
30Joe Bloggs29Perm, localMale6/6/22TechnicalSouth Africa
31Joe Bloggs30Perm, localMale6/10/22TechnicalSouth Africa
32Joe Bloggs31ExpatMale10/15/16COO's OfficeCanada
33Joe Bloggs32Perm, localMale2/1/20COO's OfficeCanada
34Joe Bloggs33Perm, localFemale10/2/172/14/18FinanceCanada
35Joe Bloggs34Perm, localFemale2/8/166/22/16CommunicationsCanada
36Joe Bloggs35Perm, localFemale2/14/226/29/22CEO’s OfficeCanada
37Joe Bloggs36Perm, localMale2/6/186/21/18FinanceGroup Netherlands
38Joe Bloggs37Perm, localMale1/1/015/16/01CEO’s OfficeGroup US
39Joe Bloggs38Perm, localMale12/1/154/14/16ITGroup US
40Joe Bloggs39Perm, localFemale7/7/1511/19/15CEO’s OfficeGroup US
41Joe Bloggs40Perm, localMale9/1/201/14/21Group US
42Joe Bloggs41Perm, localFemale7/19/2112/1/21CEO’s OfficeGroup US
43Joe Bloggs42Perm, localMale1/4/225/19/22CEO’s OfficeGroup US
44Joe Bloggs43Perm, localMale3/1/227/14/22CEO’s OfficeGroup US
45Joe Bloggs44Perm, localFemale5/10/229/22/22Group US
46Joe Bloggs45Perm, localMale5/9/229/21/22OperationsBrazil
47Joe Bloggs46Perm, localFemale5/9/229/21/22FinanceBrazil
48Joe Bloggs47Perm, localFemale5/9/229/21/22Supply ChainBrazil
49Joe Bloggs48Perm, localFemale5/2/229/14/22HRBrazil
50Joe Bloggs49Perm, localFemale5/2/229/14/22Real Estate & Property ManagementBrazil
51Joe Bloggs50Perm, localMale5/2/229/14/22TechnicalBrazil
52Joe Bloggs51Perm, localMale4/18/22OperationsBrazil
53Joe Bloggs52Perm, localMale4/18/22Implementation / EngineeringBrazil
54Joe Bloggs53Perm, localMale4/18/22Implementation / EngineeringBrazil
55Joe Bloggs54Perm, localMale4/4/226/16/22OperationsBrazil
56Joe Bloggs55Perm, localMale4/4/226/16/22OperationsBrazil
57Joe Bloggs56Perm, localMale4/4/226/16/22TechnicalBrazil
58Joe Bloggs57Perm, localMale4/4/226/16/22PurchasingBrazil
59Joe Bloggs58Perm, localMale3/21/22TechnicalBrazil
60Joe Bloggs59Perm, localMale3/21/22Supply ChainBrazil
61Joe Bloggs60Perm, localMale3/21/22ITBrazil
62Joe Bloggs61Perm, localFemale3/21/22OperationsBrazil
63Joe Bloggs62Perm, localMale3/21/22FinanceBrazil
64Joe Bloggs63Perm, localMale3/14/22OperationsBrazil
65Joe Bloggs64Perm, localMale3/14/22TechnicalBrazil
66Joe Bloggs65Perm, localMale3/14/22TechnicalBrazil
67Joe Bloggs66Perm, localMale3/7/22Implementation / EngineeringBrazil
68Joe Bloggs67Perm, localFemale3/7/22FinanceBrazil
69Joe Bloggs68Perm, localMale3/7/22ITBrazil
70Joe Bloggs69Perm, localMale3/7/22ITBrazil
71Joe Bloggs70Perm, localMale3/7/22ITBrazil
72Joe Bloggs71Perm, localFemale2/21/22FinanceBrazil
73Joe Bloggs72Perm, localFemale2/21/22Supply ChainBrazil
74Joe Bloggs73Perm, localFemale2/7/22TechnicalBrazil
75Joe Bloggs74Perm, localMale2/7/22TechnicalBrazil
76Joe Bloggs75Perm, localMale2/7/22TechnicalBrazil
77Joe Bloggs76Perm, localMale2/7/22OperationsBrazil
78Joe Bloggs77Perm, localMale2/7/22TechnicalBrazil
79Joe Bloggs78Perm, localMale2/7/22TechnicalBrazil
80Joe Bloggs79Perm, localFemale2/7/22ITBrazil
81Joe Bloggs80Perm, localMale2/7/22TechnicalBrazil
82Joe Bloggs81Perm, localFemale2/1/22LegalBrazil
83Joe Bloggs82Perm, localMale2/1/22OperationsBrazil
84Joe Bloggs83Perm, localMale2/1/22TechnicalBrazil
85Joe Bloggs84Perm, localMale1/17/222/1/22FinanceBrazil
86Joe Bloggs85Perm, localMale1/17/22TechnicalBrazil
87Joe Bloggs86Perm, localMale1/17/22PurchasingBrazil
88Joe Bloggs87Perm, localFemale1/17/22TechnicalBrazil
89Joe Bloggs88Perm, localFemale1/17/22HR & AdminBrazil
90Joe Bloggs89Perm, localMale1/10/22OperationsBrazil
91Joe Bloggs90Perm, localMale1/10/22Implementation / EngineeringBrazil
92Joe Bloggs91Perm, localFemale1/10/22OperationsBrazil
93Joe Bloggs92Perm, localMale1/10/22TechnicalBrazil
94Joe Bloggs93Perm, localMale1/10/22TechnicalBrazil
95Joe Bloggs94Perm, localFemale1/10/22TechnicalBrazil
96Joe Bloggs95Perm, localMale1/10/22TechnicalBrazil
97Joe Bloggs96Perm, localMale1/10/22TechnicalBrazil
98Joe Bloggs97Perm, localFemale12/6/21HSEBrazil
99Joe Bloggs98Perm, localMale12/1/21LegalBrazil
100Joe Bloggs99Perm, localMale12/1/21HRBrazil
101Joe Bloggs100Perm, localFemale12/1/21HRBrazil
102Joe Bloggs101Perm, localMale12/1/21PMOBrazil
103Joe Bloggs102Perm, localFemale12/1/21PurchasingBrazil
104Joe Bloggs103Perm, localMale12/1/21CEO’s OfficeBrazil
105Joe Bloggs104Perm, localFemale11/17/21FinanceBrazil
106Joe Bloggs105Perm, localMale11/17/21CTO's OfficeBrazil
107Joe Bloggs106Perm, localMale11/17/21FinanceBrazil
108Joe Bloggs107Perm, localFemale11/1/21OperationsBrazil
109Joe Bloggs108Perm, localMale11/1/21OperationsBrazil
110Joe Bloggs109Perm, localMale11/1/21OperationsBrazil
111Joe Bloggs110Perm, localMale11/1/21TechnicalBrazil
Sample
Cell Formulas
RangeFormula
E3:E9E3=D3+60
E14:E21E14=D14+25
E34:E51E34=D34+135
E55:E58E55=D55+73
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Does this give you what you want?

maxim642.xlsx
ABCDEFGHIJKLMNOPQRSTU
1Full NameContract TypeSexStart DateLeave DateDepartmentReporting CountrySouth Africa
2Joe Bloggs1ContractorMale1/10/22TechnicalSouth AfricaContract TypeJan-22Feb-22Mar-22Apr-22May-22Jun-22Jul-22Aug-22Sep-22Oct-22Nov-22Dec-22
3Joe Bloggs2Perm, localMale1/17/223/18/22CEO’s OfficeSouth AfricaContractor111111111111
4Joe Bloggs3Perm, localFemale2/14/224/15/22CEO’s OfficeSouth AfricaPerm, local12221120131313131313
5Joe Bloggs4FTCMale2/28/224/29/22LegalSouth AfricaFTC016641111111
6Joe Bloggs5FTCFemale3/1/224/30/22LegalSouth AfricaExpat000000000000
7Joe Bloggs6FTCFemale3/7/225/6/22LegalSouth Africa
8Joe Bloggs7FTCMale3/11/225/10/22LegalSouth Africa
9Joe Bloggs8FTCFemale3/15/225/14/22LegalSouth Africa
10Joe Bloggs9FTCFemale3/22/22LegalSouth AfricaCanada
11Joe Bloggs10Perm, localMale4/25/22TechnicalSouth AfricaContract TypeJan-22Feb-22Mar-22Apr-22May-22Jun-22Jul-22Aug-22Sep-22Oct-22Nov-22Dec-22
12Joe Bloggs11Perm, localMale5/1/22TechnicalSouth AfricaContractor000000000000
13Joe Bloggs12Perm, localFemale5/1/22HRSouth AfricaPerm, local122222111111
14Joe Bloggs13Perm, localMale5/1/225/26/22SecuritySouth AfricaFTC000000000000
15Joe Bloggs14Perm, localMale5/9/226/3/22TechnicalSouth AfricaExpat111111111111
16Joe Bloggs15Perm, localFemale5/16/226/10/22TechnicalSouth Africa
17Joe Bloggs16Perm, localMale5/23/226/17/22TechnicalSouth Africa
18Joe Bloggs17Perm, localMale5/23/226/17/22TechnicalSouth Africa
19Joe Bloggs18Perm, localMale5/25/226/19/22TechnicalSouth AfricaBrazil
20Joe Bloggs19Perm, localMale5/20/226/14/22SecuritySouth AfricaContract TypeJan-22Feb-22Mar-22Apr-22May-22Jun-22Jul-22Aug-22Sep-22Oct-22Nov-22Dec-22
21Joe Bloggs20Perm, localMale5/24/226/18/22TechnicalSouth AfricaContractor000000000000
22Joe Bloggs21Perm, localMale6/1/22TechnicalSouth AfricaPerm, local274052596565616161555555
23Joe Bloggs22Perm, localMale6/1/22TechnicalSouth AfricaFTC000000000000
24Joe Bloggs23Perm, localMale6/1/22TechnicalSouth AfricaExpat000000000000
25Joe Bloggs24Perm, localMale6/1/22TechnicalSouth Africa
26Joe Bloggs25Perm, localMale6/1/22TechnicalSouth Africa
Sheet1
Cell Formulas
RangeFormula
J3:J6J3=SUMPRODUCT(($G$2:$G$111=$I$1)*($B$2:$B$111=$I3)*($D$2:$D$111<=J$2)*(($E$2:$E$111>(J$2-DAY(J$2)))+($E$2:$E$111="")))
K3:U6K3=SUMPRODUCT(($G$2:$G$111=$I$1)*($B$2:$B$111=$I3)*($D$2:$D$111<=K$2)*(($E$2:$E$111>J$2)+($E$2:$E$111="")))
E3:E9E3=D3+60
J12:J15J12=SUMPRODUCT(($G$2:$G$111=$I$10)*($B$2:$B$111=$I12)*($D$2:$D$111<=J$2)*(($E$2:$E$111>(J$2-DAY(J$2)))+($E$2:$E$111="")))
K12:U15K12=SUMPRODUCT(($G$2:$G$111=$I$10)*($B$2:$B$111=$I12)*($D$2:$D$111<=K$2)*(($E$2:$E$111>J$2)+($E$2:$E$111="")))
E14:E21E14=D14+25
J21:J24J21=SUMPRODUCT(($G$2:$G$111=$I$19)*($B$2:$B$111=$I21)*($D$2:$D$111<=J$2)*(($E$2:$E$111>(J$2-DAY(J$2)))+($E$2:$E$111="")))
K21:U24K21=SUMPRODUCT(($G$2:$G$111=$I$19)*($B$2:$B$111=$I21)*($D$2:$D$111<=K$2)*(($E$2:$E$111>J$2)+($E$2:$E$111="")))
 
Upvote 0
Another option
Excel Formula:
=COUNT(FILTER(ROW($G$2:$G$100),($G$2:$G$100=$I$1)*($B$2:$B$100=$I3)*($D$2:$D$100<=J$2)*(($E$2:$E$100>EOMONTH(J$2,-1))+($E$2:$E$100="")),""))
 
Upvote 0
Solution
Another option
Excel Formula:
=COUNT(FILTER(ROW($G$2:$G$100),($G$2:$G$100=$I$1)*($B$2:$B$100=$I3)*($D$2:$D$100<=J$2)*(($E$2:$E$100>EOMONTH(J$2,-1))+($E$2:$E$100="")),""))
Thank you!
 
Upvote 0
Does this give you what you want?

maxim642.xlsx
ABCDEFGHIJKLMNOPQRSTU
1Full NameContract TypeSexStart DateLeave DateDepartmentReporting CountrySouth Africa
2Joe Bloggs1ContractorMale1/10/22TechnicalSouth AfricaContract TypeJan-22Feb-22Mar-22Apr-22May-22Jun-22Jul-22Aug-22Sep-22Oct-22Nov-22Dec-22
3Joe Bloggs2Perm, localMale1/17/223/18/22CEO’s OfficeSouth AfricaContractor111111111111
4Joe Bloggs3Perm, localFemale2/14/224/15/22CEO’s OfficeSouth AfricaPerm, local12221120131313131313
5Joe Bloggs4FTCMale2/28/224/29/22LegalSouth AfricaFTC016641111111
6Joe Bloggs5FTCFemale3/1/224/30/22LegalSouth AfricaExpat000000000000
7Joe Bloggs6FTCFemale3/7/225/6/22LegalSouth Africa
8Joe Bloggs7FTCMale3/11/225/10/22LegalSouth Africa
9Joe Bloggs8FTCFemale3/15/225/14/22LegalSouth Africa
10Joe Bloggs9FTCFemale3/22/22LegalSouth AfricaCanada
11Joe Bloggs10Perm, localMale4/25/22TechnicalSouth AfricaContract TypeJan-22Feb-22Mar-22Apr-22May-22Jun-22Jul-22Aug-22Sep-22Oct-22Nov-22Dec-22
12Joe Bloggs11Perm, localMale5/1/22TechnicalSouth AfricaContractor000000000000
13Joe Bloggs12Perm, localFemale5/1/22HRSouth AfricaPerm, local122222111111
14Joe Bloggs13Perm, localMale5/1/225/26/22SecuritySouth AfricaFTC000000000000
15Joe Bloggs14Perm, localMale5/9/226/3/22TechnicalSouth AfricaExpat111111111111
16Joe Bloggs15Perm, localFemale5/16/226/10/22TechnicalSouth Africa
17Joe Bloggs16Perm, localMale5/23/226/17/22TechnicalSouth Africa
18Joe Bloggs17Perm, localMale5/23/226/17/22TechnicalSouth Africa
19Joe Bloggs18Perm, localMale5/25/226/19/22TechnicalSouth AfricaBrazil
20Joe Bloggs19Perm, localMale5/20/226/14/22SecuritySouth AfricaContract TypeJan-22Feb-22Mar-22Apr-22May-22Jun-22Jul-22Aug-22Sep-22Oct-22Nov-22Dec-22
21Joe Bloggs20Perm, localMale5/24/226/18/22TechnicalSouth AfricaContractor000000000000
22Joe Bloggs21Perm, localMale6/1/22TechnicalSouth AfricaPerm, local274052596565616161555555
23Joe Bloggs22Perm, localMale6/1/22TechnicalSouth AfricaFTC000000000000
24Joe Bloggs23Perm, localMale6/1/22TechnicalSouth AfricaExpat000000000000
25Joe Bloggs24Perm, localMale6/1/22TechnicalSouth Africa
26Joe Bloggs25Perm, localMale6/1/22TechnicalSouth Africa
Sheet1
Cell Formulas
RangeFormula
J3:J6J3=SUMPRODUCT(($G$2:$G$111=$I$1)*($B$2:$B$111=$I3)*($D$2:$D$111<=J$2)*(($E$2:$E$111>(J$2-DAY(J$2)))+($E$2:$E$111="")))
K3:U6K3=SUMPRODUCT(($G$2:$G$111=$I$1)*($B$2:$B$111=$I3)*($D$2:$D$111<=K$2)*(($E$2:$E$111>J$2)+($E$2:$E$111="")))
E3:E9E3=D3+60
J12:J15J12=SUMPRODUCT(($G$2:$G$111=$I$10)*($B$2:$B$111=$I12)*($D$2:$D$111<=J$2)*(($E$2:$E$111>(J$2-DAY(J$2)))+($E$2:$E$111="")))
K12:U15K12=SUMPRODUCT(($G$2:$G$111=$I$10)*($B$2:$B$111=$I12)*($D$2:$D$111<=K$2)*(($E$2:$E$111>J$2)+($E$2:$E$111="")))
E14:E21E14=D14+25
J21:J24J21=SUMPRODUCT(($G$2:$G$111=$I$19)*($B$2:$B$111=$I21)*($D$2:$D$111<=J$2)*(($E$2:$E$111>(J$2-DAY(J$2)))+($E$2:$E$111="")))
K21:U24K21=SUMPRODUCT(($G$2:$G$111=$I$19)*($B$2:$B$111=$I21)*($D$2:$D$111<=K$2)*(($E$2:$E$111>J$2)+($E$2:$E$111="")))
Thank you.
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,149
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top