SUMPRODUCT formula needed to count headcount based on date input in cell A1, split by department.

maxim642

Board Regular
Joined
Feb 4, 2021
Messages
91
Office Version
  1. 365
Platform
  1. MacOS
I want to summarise headcount volumes per department based on the date input in cell A1.

Headcount calculation is based on a combination of the "Hire Date" & the "Current Employment: End Date". An employee should only be counted if their hire date is equal to OR less than the date in cell A1 AND their end date is either blank OR equal to OR greater than the date in A1.

I want to be able to break the headcounts by the department.

Below is an example of what my dataset looks like.

I would like the formula to go into cells H2:H4

I tried using SUMPRODUCT but I couldn't get it to work. Perhaps, there's a simpler way? Thanks in advance!!

Master_Template_Exinity.xlsx
ABCDEFGH
19/30/21Hire DateCurrent Employment: End DateCurrent Employment DepartmentHeadcount per Date (A1)
21/22/19Dep1Dep1
37/4/155/12/18Dep1Dep2
49/4/16Dep1Dep3
52/1/20Dep1
611/23/20Dep1
75/25/185/30/21Dep1
82/11/21Dep1
99/9/20Dep2
109/17/1812/3/19Dep2
1112/31/18Dep2
128/27/21Dep2
133/12/1910/8/19Dep2
1412/10/18Dep2
156/3/167/25/17Dep2
162/6/21Dep3
179/26/19Dep3
186/5/158/8/18Dep3
197/31/1512/16/15Dep3
208/26/21Dep3
211/20/1511/8/20Dep3
221/1/206/12/21Dep3
234/27/16Dep3
2410/25/18Dep3
257/19/165/13/17Dep2
268/11/20Dep2
273/27/20Dep2
282/15/21Dep2
2912/23/162/8/17Dep2
305/16/16Dep2
315/30/19Dep1
3210/9/20Dep1
338/11/155/7/18Dep1
3410/28/153/14/19Dep1
358/20/19Dep1
363/6/21Dep1
376/23/16Dep1
387/5/21Dep1
397/19/21Dep1
4012/19/157/21/17Dep3
415/4/1712/12/17Dep3
426/30/19Dep3
431/2/17Dep3
447/25/19Dep3
451/27/19Dep3
466/17/206/21/21Dep3
479/28/19Dep3
484/11/189/30/18Dep3
Sheet1
 
You are missing a couple of * in there, also you should not use the sheet name of the sheet the formula is in and using whole column references is a bad idea as it can slow your workbook down considerably.
Excel Formula:
=SUMPRODUCT(('ORC Template'!SH:SH<=$B$2)*(('ORC Template'!$I:$I="")+('ORC Template'!$I:$I>=$B$2))*('ORC Template'!SM:SM=B10))
Thanks, though I'm still not returning any values. I've uploaded screenshots of the 2 worksheets I'm using. I'm sure it must be something to do with the dates but I can't see the issue.
 
Upvote 0

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Can you answer my question from post#7?
 
Upvote 0
It's rather bizarre: the dates do appear to be recognised as dates: I did a quick formula in an adjacent column to count the number of days between the dates using NETWORKDAYS and it gave the expected results.

Are COUNTIFS not generally recommended for counting between dates?
 
Upvote 0
The syntax that follows also works.
Edit for location of criteria, the locations of columns of interest, and the appropriate range for the data.
The formula in Column D also works; it was edited.
N.B. You can post an extract of your data with the forum's tool XL2BB.

T202110a.xlsm
ABCD
1
230-Sep-21
3
4
5
6
7
8
9Headcount per Date
10Dep11212
11Dep288
12Dep31010
13
1d
Cell Formulas
RangeFormula
C10:C12C10=SUMPRODUCT(--('ORC Template'!$M$2:$M$500=B10),--('ORC Template'!$H$2:$H$500<=$B$2),--(('ORC Template'!$I$2:$I$500="")+('ORC Template'!$I$2:$I$500>$B$2)))
D10:D12D10=SUMPRODUCT(('ORC Template'!$H$2:$H$500<=$B$2)*(('ORC Template'!$I$2:$I$500="")+('ORC Template'!$I$2:$I$500>=$B$2))*('ORC Template'!$M$2:$M$500=B10))
 
Upvote 0

Forum statistics

Threads
1,223,250
Messages
6,171,036
Members
452,374
Latest member
keccles

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