Forum Discussion

NoviceKB's avatar
NoviceKB
Brass Contributor
Jul 15, 2020

Using Countifs to Calculate Headcounts

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

  • OwenPrice's avatar
    OwenPrice
    Iron Contributor

    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

    • NoviceKB's avatar
      NoviceKB
      Brass Contributor

      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.

      • OwenPrice's avatar
        OwenPrice
        Iron Contributor

        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.

  • mathetes's avatar
    mathetes
    Silver Contributor

    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.

     

Resources