Using Countifs to Calculate Headcounts

%3CLINGO-SUB%20id%3D%22lingo-sub-1524465%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20Countifs%20to%20Calculate%20Headcounts%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1524465%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F677879%22%20target%3D%22_blank%22%3E%40NoviceKB%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECould%20I%20offer%20a%20suggestion%3F%20Let's%20make%20it%20simpler.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYour%20set%20of%20conditions%20is%20complex%20enough%20that%20you%20might%20be%20better%20suited%20to%20the%20use%20of%20%22helper%20columns%22%20to%20test%20one%20or%20at%20most%20two%20conditions%20and%20yield%20a%20%22Y%22%20or%20some%20other%20value%2C%20that%20could%20then%20be%20used%20as%20the%20basis%20for%20counting.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESee%20the%20attached.%20I%20didn't%20try%20to%20verify%20the%20number...will%20leave%20that%20to%20you.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1524564%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20Countifs%20to%20Calculate%20Headcounts%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1524564%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F677879%22%20target%3D%22_blank%22%3E%40NoviceKB%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThese%20two%20statements%20appear%20to%20cancel%20each%20other%20out%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3COL%3E%3CLI%3EThe%20probation%20enddate%20is%20more%20than%20TODAY%20or%20BLANK%20and%20the%20Probation%20status%20is%20NOT%20%22Terminated%22%3C%2FLI%3E%3CLI%3E(If%20status%20is%20Terminated%20but%20the%20probation%20enddate%20is%20later%20than%20todays%20date%20or%20BLANK%2C%20this%20should%20still%20count%20as%201%20Headcount)%3C%2FLI%3E%3C%2FOL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20seem%20to%20be%20saying%20that%20regardless%20of%20the%20probation%20status%2C%20if%20the%20probation%20end%20date%20is%20greater%20than%20today%20or%20blank%2C%20then%20it%20should%20count%20as%20a%20headcount.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20mean%20to%20say%20that%20the%20probation%20end%20date%20must%20not%20be%20%3CEM%3Ebefore%3C%2FEM%3E%20today%20(i.e.%20it%20can%20be%20today%2C%20after%20today%2C%20or%20empty)%2C%20then%20use%20this%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DCOUNTIFS(Table1%5BEmployee%20Class%5D%2C%22%26lt%3B%26gt%3BAdecco%22%2CTable1%5BEmployee%20Class%5D%2C%22%26lt%3B%26gt%3B%22%2CTable1%5BContract%20Start%20Date%5D%2C%22%26lt%3B%3D%22%26amp%3BTODAY()%2CTable1%5BProbation%20Enddate%5D%2C%22%26gt%3B%3D%22%26amp%3BTODAY()%2CTable1%5BProbation%20Status%5D%2C%22%26lt%3B%26gt%3BTerminated%22)%2BCOUNTIFS(Table1%5BEmployee%20Class%5D%2C%22%26lt%3B%26gt%3BAdecco%22%2CTable1%5BEmployee%20Class%5D%2C%22%26lt%3B%26gt%3B%22%2CTable1%5BContract%20Start%20Date%5D%2C%22%26lt%3B%3D%22%26amp%3BTODAY()%2CTable1%5BProbation%20Enddate%5D%2C%22%22%2CTable1%5BProbation%20Status%5D%2C%22%26lt%3B%26gt%3BTerminated%22)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20actually%20summing%20these%20two%20counts%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E1.%20Non-Adecco%20employees%20whose%20class%20is%20known%20and%20whose%20contract%20start%20date%20is%20before%20or%20on%20today%20with%20%3CSTRONG%3Ea%20probation%20date%20on%20or%20after%20today%3C%2FSTRONG%3E%20who%20have%20not%20been%20terminated%2C%20AND%3C%2FP%3E%3CP%3E2.%20Non-Adecco%20employees%20whose%20class%20is%20known%20and%20whose%20contract%20start%20date%20is%20before%20or%20on%20today%20with%20%3CSTRONG%3Eno%20probation%20date%3C%2FSTRONG%3E%20who%20have%20not%20been%20terminated%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1523476%22%20slang%3D%22en-US%22%3EUsing%20Countifs%20to%20Calculate%20Headcounts%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1523476%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EHi%20Team%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%3EIn%20my%20attached%20screenshot%20I%20am%20wondering%20how%20I%20can%20use%20COUNTIFS%20to%20calculate%20the%20current%20Headcount%20of%20employees%20based%20on%20the%20following%20conditions.%3C%2FSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%3ECountifs%3B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E1.%20The%20employee%20class%20is%20NOT%20%22Adecco%22%20nor%20Blank.%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E2.%20The%20Contract%20Startdate%20is%20less%20than%20TODAY(todays%20date)%20and%20not%20blank.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E3.%20Probation%20status%20is%20NOT%20%22Terminated%22%20(If%20status%20is%20Terminated%20but%20the%20contract%20enddate%20is%20later%20than%20todays%20date%20or%20BLANK%2C%20this%20should%20still%20count%20as%201%20Headcount)%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3ECurrently%20this%20is%20my%20formula%3A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3E%3DCOUNTIFS(B%3AB%2C%22%26lt%3B%26gt%3BAdecco%22%2CB%3AB%2C%22%26lt%3B%26gt%3B%22%2CC%3AC%2C%22%26lt%3B%3DTODAY()%22%2CE%3AE%2C%22%26gt%3B%3DTODAY()%22%2CF%3AF%2C%22%26lt%3B%26gt%3BTerminated%22)%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EBut%20it%20returns%20zero...%20%3CLI-EMOJI%20id%3D%22lia_disappointed-face%22%20title%3D%22%3Adisappointed_face%3A%22%3E%3C%2FLI-EMOJI%3E%20%3A(...Any%20ideas%20will%20be%20very%20welcome.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EThanks.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1523476%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1525019%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20Countifs%20to%20Calculate%20Headcounts%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1525019%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F677879%22%20target%3D%22_blank%22%3E%40NoviceKB%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECan%20you%20confirm%20this%20is%20what%20you%20mean%3F%20If%20we%20break%20each%20condition%20down%20into%20bullets%20of%20their%20own%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3COL%3E%3CLI%3EThe%20employee%20class%20is%20not%20%22Adecco%22%2C%20AND%3C%2FLI%3E%3CLI%3EThe%20employee%20class%20is%20not%20blank%2C%20AND%3C%2FLI%3E%3CLI%3EThe%20contract%20start%20date%20is%20less%20than%20today's%20date%2C%20AND%3C%2FLI%3E%3CLI%3EThe%20contract%20start%20date%20is%20not%20blank%2C%20AND%3C%2FLI%3E%3CLI%3EEither%3A%3COL%3E%3CLI%3EThe%20probation%20status%20is%20not%20terminated%2C%20OR%3C%2FLI%3E%3CLI%3EThe%20probation%20status%20is%20terminated%20AND%3COL%3E%3CLI%3E%3CSTRONG%3Ethe%20contract%20end%20date%3C%2FSTRONG%3E%20is%20after%20today%2C%20OR%3C%2FLI%3E%3CLI%3E%3CSTRONG%3Ethe%20contract%20end%20date%3C%2FSTRONG%3E%20is%20blank%3C%2FLI%3E%3C%2FOL%3E%3C%2FLI%3E%3C%2FOL%3E%3C%2FLI%3E%3C%2FOL%3E%3CP%3ERegarding%20the%20bold%20items%20-%20should%20those%20actually%20be%20probation%20end%20date%3F%20I%20wonder%20whether%20the%20actual%20situation%20you're%20trying%20to%20capture%20here%20are%20people%20who%20have%20been%20terminated%20but%20they%20have%20not%20finished%20their%20probation%20yet%2C%20so%20they%20are%20still%20active%20headcount.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1524843%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20Countifs%20to%20Calculate%20Headcounts%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1524843%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F725726%22%20target%3D%22_blank%22%3E%40OwenPrice%3C%2FA%3E%26nbsp%3BMany%20thanks%20for%20your%20observation%20and%20you%20are%20absolutely%20right!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20modified%20my%20initial%20submission.%20Can%20you%20take%20a%20look%20and%20let%20me%20know%20if%20this%20makes%20sense%20to%20you%3F%20It%20does%20to%20me%20now.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20yes%2C%20how%20can%20I%20capture%20this%20with%20a%20formula%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

Hi Team,

In my attached screenshot I am wondering how I can use COUNTIFS to calculate the current Headcount of employees based on the following conditions.

Countifs;
1. The employee class is NOT "Adecco" nor Blank.
2. The Contract Startdate is less than TODAY(todays date) and not blank.

3. Probation status is NOT "Terminated" (If status is Terminated but the contract enddate is later than todays date or BLANK, this should still count as 1 Headcount)

 

Currently this is my formula:

 

=COUNTIFS(B:B,"<>Adecco",B:B,"<>",C:C,"<=TODAY()",E:E,">=TODAY()",F:F,"<>Terminated")

 

But it returns zero... :(...Any ideas will be very welcome.

 

Thanks.

 

 

6 Replies

@NoviceKB 

 

Could I offer a suggestion? Let's make it simpler.

 

Your set of conditions is complex enough that you might be better suited to the use of "helper columns" to test one or at most two conditions and yield a "Y" or some other value, that could then be used as the basis for counting.

 

See the attached. I didn't try to verify the number...will leave that to you.

 

@NoviceKB 

 

These two statements appear to cancel each other out:

 

  1. The probation enddate is more than TODAY or BLANK and the Probation status is NOT "Terminated"
  2. (If status is Terminated but the probation enddate is later than todays date or BLANK, this should still count as 1 Headcount)

 

You seem to be saying that regardless of the probation status, if the probation end date is greater than today or blank, then it should count as a headcount.

 

If you mean to say that the probation end date must not be before today (i.e. it can be today, after today, or empty), then use this:

 

 

=COUNTIFS(Table1[Employee Class],"<>Adecco",Table1[Employee Class],"<>",Table1[Contract Start Date],"<="&TODAY(),Table1[Probation Enddate],">="&TODAY(),Table1[Probation Status],"<>Terminated")+COUNTIFS(Table1[Employee Class],"<>Adecco",Table1[Employee Class],"<>",Table1[Contract Start Date],"<="&TODAY(),Table1[Probation Enddate],"",Table1[Probation Status],"<>Terminated")

 

 

This is actually summing these two counts:

 

1. Non-Adecco employees whose class is known and whose contract start date is before or on today with a probation date on or after today who have not been terminated, AND

2. Non-Adecco employees whose class is known and whose contract start date is before or on today with no probation date who have not been terminated

@OwenPrice Many thanks for your observation and you are absolutely right!

 

I have modified my initial submission. Can you take a look and let me know if this makes sense to you? It does to me now.

 

If yes, how can I capture this with a formula?

 

Thanks.

@NoviceKB 

 

Can you confirm this is what you mean? If we break each condition down into bullets of their own:

 

  1. The employee class is not "Adecco", AND
  2. The employee class is not blank, AND
  3. The contract start date is less than today's date, AND
  4. The contract start date is not blank, AND
  5. Either:
    1. The probation status is not terminated, OR
    2. The probation status is terminated AND
      1. the contract end date is after today, OR
      2. the contract end date is blank

Regarding the bold items - should those actually be probation end date? I wonder whether the actual situation you're trying to capture here are people who have been terminated but they have not finished their probation yet, so they are still active headcount.

Hi @OwenPrice !

 

Yes to points 1 through 4.

 

Regarding your point 5, as you see from my test sheet, the probation column will have those who have completed probation or have their probation ongoing. These 2 categories of staff should of course be counted as part of the current HC. What I wanted to capture in addition to the above two categories is exactly what you mentioned in your point 5.2.1. Normally once we terminate someones probation we align the contract enddate to the probation enddate but for the sake of the formula please use only PROBATION ENDDATE though.

 

Thanks and have a goodnight!

 

Your support is much much appreciated!

 

@NoviceKB 

 

I think this formula will do what you need. It returns 24 rows from your sample data:

=COUNTIFS(Table1[Employee Class],"<>Adecco",Table1[Employee Class],"<>",Table1[Contract Start Date],"<="&TODAY(),Table1[Contract Start Date],"<>",Table1[Probation Status],"<>Terminated")+COUNTIFS(Table1[Employee Class],"<>Adecco",Table1[Employee Class],"<>",Table1[Contract Start Date],"<="&TODAY(),Table1[Contract Start Date],"<>",Table1[Probation Status],"Terminated",Table1[Probation Enddate],">="&TODAY())

 

Please see attached.