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
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
How about
Excel Formula:
=SUMPRODUCT(($C$2:$C$50<=$A$1)*(($D$2:$D$50="")+($D$2:$D$50>=$A$1))*($E$2:$E$50=G2))
 
Upvote 0
try
T202110a.xlsm
ABCDEFGH
130-Sep-21Hire Date Employ End DateDeptHeadcount per Date (A1)
222-Jan-19Dep1Dep112
34-Jul-1512-May-18Dep1Dep28
44-Sep-16Dep1Dep310
1c
Cell Formulas
RangeFormula
H2:H4H2=SUMPRODUCT(--($E$2:$E$48=G2),--($C$2:$C$48<=$A$1),--(($D$2:$D$48="")+($D$2:$D$48>$A$1)))
 
Upvote 0
How about
Excel Formula:
=SUMPRODUCT(($C$2:$C$50<=$A$1)*(($D$2:$D$50="")+($D$2:$D$50>=$A$1))*($E$2:$E$50=G2))
Thanks. So, this worked in the sample dataset worksheet I used but when I used it in the "real" worksheet, it returned 0 values. I'm wondering if it has anything to do with the fact the data source is formatted as a table?
 
Upvote 0
Being in a table will not make any difference. Check that all your dates are real dates & not text.
 
Upvote 0
Being in a table will not make any difference. Check that all your dates are real dates & not text.
I thought that might have been the issue but it doesn't appear to be.

Do you know whether a COUNTIFS could work?
 
Upvote 0
If your change the cell format for all the dates to General, what do you see?
 
Upvote 0
If your change the cell format for all the dates to General, what do you see?
This is driving me demented!! :eek:

So, this is currently the formula that I'm using

=SUMPRODUCT(('ORC Template'!SH:SH<=Calcs!$B$2)(('ORC Template'!$I: $I=''') +('ORC Template'!$I:$I>=Calcs!$B$2)) ('ORC Template '!SM:SM=Calcs!B10))

The ORC Template is worksheet 1 (main data source) and I'm pulling that information in the Calcs tab (worksheet 2).

Have I messed up the syntax as they are on separate worksheets?
 
Upvote 0
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))
 
Upvote 0
Calcs tab.PNG
ORC tab.PNG
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,928
Members
449,094
Latest member
teemeren

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