Comments on: How to use Excel COUNTIFS and COUNTIF with multiple criteria

The tutorial explains how to use COUNTIFS and COUNTIF formulas with multiple criteria in Excel. You will find a number of examples for different data types – numbers, dates, text, wildcard characters, non-blank cells and more. Continue reading

Comments page 48. Total comments: 2055

  1. thanks a lot Svetlana, it is really very helpful

  2. Hi,

    I have a table in excel with dates, times and list of random names for each day at different times.
    I would like to be able to count how many times all the different names appear. It is very much like an attendance sheet (only I'm trying to count non attendances), with session starting every 30 minutes. Ideally, I would also like to know times and dates with most non attendances.

    Thank you very much for your help.

  3. Hi.

    I wanted to know how to write a formula in Excel for the following:

    Suppose there are variable names available in individual cells in a column in one sheet. Excel needs to count (and subsequently sum up) the number of times those names appear in a column in another sheet and display the answer in a cell in another sheet.

    Greatly appreciate your assistance on this.

    Regards,
    Ken

    1. Hi Ken,

      Your Countif formula may look similar to this:
      =COUNTIF(Sheet2!A2:A100, Sheet1!A2)

      Where column A in sheet2 is where all the different names appear, and A2 in sheet1 is an individual cell with a variable name you want to count.

  4. Hi,
    i want to know how can i count in given below table there is final result is latest revision.

    No. Rev.00 Rev.01 Rev.02

    1 C D B
    2 C B B
    3 D C B
    4 D B A

  5. Time Criteria using counti if
    =countif(A1:A100,"<="&TIME(10,0,0))

    I want to know how many people arrived before 10 AM from that column.

    Excel is not giving the output.

    Would b great if anyone could help

    1. Hi Sourav,

      Try this one:

      =COUNTIF(A1:A100,"<="&TIMEVALUE("10:00 AM"))

  6. Hi Svetlana,

    I am working on date range and I want to get the weekly counts with inclusive dates. Can you pls. help me how to figure out the cell reference with variable dates?

    Thanks in advance,
    Jose

  7. Thanks Svetlana for helping me and resolve all my statistic issues.

  8. hi i want to use cell as a criteria by counti formula,
    and i could not find out solution. is it possible?
    if possible how i can do it

    1. Hi Kerem,

      Of course, you can use a cell reference as a criteria. In this case, you enclose the operator in quotation marks and add an ampersand (&) before the cell. For example:
      =COUNTIFS(A2:A10,">"&$D$3)

  9. Hello,

    Thank you for your helpful tips however I have a scenario non-applicable to the ones you have provided. I'd greatly appreciate if you could help me create a formula for the following scenario:

    I need to get a count of Employee Names that do not have an assignment to an Employee Group. For Example:

    Column A
    Employee Names

    Column B
    Employee Group

    I need a count of cells to be counted only when there is text in Column A and no text in Column B.

    Currently I am using the following syntax: =Countifs(A2:A1000,"*",B2:B1000,"")

    This syntax is returning a sum of cells with formulas minus those cells with data populated.

    How can I fix this?

    1. Hi Sarah,

      Try this one:
      =COUNTIFS(A2:A1000,"<>"&"",B2:B1000,"")

  10. Hi Svetlana, I would really appreciate any help you can give me with the following:

    I have 2 columns of data like this
    Column 1 Column 2
    Beer 1
    Wine 2
    Beer 1
    Beer 2
    Wine 3

    and so on,is there a way to calculate the data to get the total amount from column 2 per item from column 1?

    Thanks in advance,

    1. Hi Kel,

      You can use a SUMIF formula similar to this:

      =SUMIF(A1:A5, "Beer", B1:B5) where column A is the product name and column B is qty.

  11. Please help me

    I want to maintain my attendance register with conditions. Like if a employee took more than 4 days leave (continuously). automatically it should display straight to his name: warning

    for example

    Attendance Register
    employee 1 : b1:af1 (31 columns for month)

    If he took 4 days leave continuously then only result should show warning message.
    If he took 1 day leave and works for 2 days and again took leave. no need to warn.

    I just need if he took continuously 4 leave days with b1:af1, result warning !

    Please help, Thanks in advance for responding to my queries

  12. I want to maintain my attendance register with conditions. Like if a employee took more than 4 days leave (continuously). automatically it should display straight to his name: warning

    for example

    Attendance Register
    employee 1 : b1:af1 (31 columns for month)

    If he took 4 days leave continuously then only result should show warning message.
    If he took 1 day leave and works for 2 days and again took leave. no need to warn.

    I just need if he took continuously 4 leave days with b1:af1, result warning !

    Please help, Thanks in advance for responding to my queries

  13. A B C D E F G H
    3000037398 0040 4
    3000022099 0410 3.6 7.6 7.6
    3000022099 0410 2.4 2.4 3 3
    3000037398 0040 5
    3000037398 0040 2.6
    3000037398 0040 2.4
    3000022099 0410 1.4 2.5

    Hi
    I would like to lookup the value / item in Column A which may appear more than once and then total up all the numbers from columns "B" to "H" relevant to the value in "A"
    i.e the total for number 3000037398 0040 will be 14.

    Thanks

  14. Hello there!
    I am working on a tracking worksheet where I would like to create a formula in sheet #2 to be able to calculate a total count of a specific LETTER CODE on a SPECIFIC DATE. The data would be in Sheet #1.
    Sheet # 1 has the following:
    Column A - dates(Example- 5/1/15, 5/2/15,etc)
    Column B - Letter Codes (Example - C, AD,L,K)

    Then I have Sheet #2. Here is where I would like a formula to show the total count of a specific LETTER CODE on a SPECIFIC DATE from sheet 1.
    Any help or guidance is EXTREMELY appreciated!!!
    Thanks in advance!!

  15. Hi,

    Sort of complicated question. I have 3 columns that I am working with. All three columns are filled with "Y" or "N" telling me a yes or no answer.

    I want to count if there is a "Y" in column B AND a "N" in column D for ONE single row and then add all those together.

    This is what I have but it is not calculating it correctly, can you help?
    =COUNTIFS(B2:B39, "Y", D2:D39, "N")

  16. Hi,

    I want to maintain my attendance register with conditions. Like if a employee took more than 4 days leave (continuously). automatically it should display straight to his name: warning

    for example

    Attendance Register
    employee 1 : b1:af1 (31 columns for month)

    If he took 4 days leave continuously then only result should show warning message.
    If he took 1 day leave and works for 2 days and again took leave. no need to warn.

    I just need if he took continuously 4 leave days with b1:af1, result warning !

    Please help, Thanks in advance for responding to my queries

  17. Looking for a formula that will add cells if another cell matches a specific value.

    Example:
    A1=1, B1=2, C1=8, D1=60
    A2=2, B2=4, C2=4, D2=80
    A3=1, B3=1, C3=12, D3=60
    A4=3, B4=2, C4=4, D4=120
    A5=3, B5=1, C5=4, D5=40
    A6=2, B6=2, C6=8, D6=80

    What I'm looking for, is B7= the sum of the values for the B column that have a 1 in it's A cell for that row. B8= the sum of the values for the B column that have a 2 in it's A cell for that row, and so forth. This is sort of what I have been looking at, but have not been able to complete it. IF(A1:A6=1,B1+B3,??

    Here is an example file: https://www.dropbox.com/s/3tbit1g63hjohw5/Book1.xlsx?dl=0

    Thank you for any help.

  18. Ms. Cheusheva

    I have a good one for you, I need to take and if column B has the word ALSE I need to count the number in column C and post the resulting total number. Any Ideas?

    Thanks for all the help

      1. Thanks for the help works great.

  19. Hi,

    I have a bill wise sale data in which i want to count how many times a category is coming.

    Setting is as follows:
    Col A: Bill number (27000 + rows including duplicates, and 2000 + rows unique)
    Col C: Time period of sale (4 time periods)
    Col D: Product code/name (multiple)
    Col H: Category (18 categories)

    Objective is to find non duplicate unique bill count (Col A), for all 18 categories (Col

    H) set in rows, and 4 time periods set in columns

    Pls. help with a formula

    Thanks
    Anmol

  20. Dear Svetlana,

    I need to create a countif formula that will allow me to start counting in multiple spots.

    I.E 0 - 0 - 0 - 0 - 100 - 100 - 0 - 200 I want it to count FOUR becuase the trend starts. I need this for multiple lines with different starting points.

    You can treat this as says and months it was a new product so we didnt have sales in the 1st 4 months, but sales started on the 5th month and we had two months with 100 cases the 7th month we didn't have any sales and the 8th month we had 200cs. - I.E we averaged 100 cases per month. 400 cases in four months.

    the next item may be

    I.E 0 - 0 - 50 - 0 - 100 - 100 - 0 - 200

    Please help. I have tried everything i can think of.

    1. Hello Tom,

      If my understanding is correct, you need a Helper Column to fulfill this task. For example, if your data are in columns A:H, then in cell I2 you need to place the following array formula (use CTRL+SHIFT+ENTER to enter it):

      =COLUMNS(A2:H2)+1-MIN(IF(A2:H2>0,COLUMN(A2:H2),9999))

      Where A2:H2 are the cells with data. You will get the number of months from the sales start (4, 6, etc.).

      Then copy the formula down across the column I.

      After that you can calculate Average in the adjacent column using this formula:
      =sum(A2:H2)/I2

  21. I need to count multiple criteria. I have a spreadsheet where the counts will be housed. This spreadsheet is looking at another spreadsheet's data to obtain the counts. In column A the city will be located. There are 7 different cities in a column. In column B there will be the project names. There will be about 4 of these. Column C has the start date and Column D has the end date. I want my formula to look at column A and find Sacramento, then look at column B for only specific project name, then look at column D for the date range of 3/26/2015 to 4/25/2015 and provide a total count.

    So for instance, Sacramento will have 4 projects listed so there will be 4 separate rows for Sacramento. One row for each project. But I only want to count two of the projects. How would I put this into a formula?

    So if the project names are Red, White, Blue, and Yellow (so 4 rows for Sacramento). I want my formula to look at column A for Sacramento and count only if column B has Red and White and column D for the date range of 3/26/2015 to 4/25/2015.

    Right now I have a formula that counts how many cells are within that date range for Sacramento but it is counting for all 4 projects. I want it to only include the date range for projects Red and White (column B).

    Thank you for your time and effort.

  22. EXPECTED ACTUAL DELIVERY STATUS
    09/01/2015 07/01/2015 LATE
    04/01/2015 31/01/2014 ONTIME
    10/01/2015 06/01/2015 LATE
    10/01/2015 LATE
    30/12/2018

    Hi,
    I would like to ask what will be the formula if I want to have the status as "Late" or "On-time" for the data table above. It will also show a "Late" status if it already lapsed the expected date even if in the "Actual Delivery" column is blank. It will also not categorize the status if the expected delivery column is blank once it is not yet past the due date.

    Thanks in advance.

    1. Hi Loy,

      You can achieve the result by using nested IF functions.

      To be able to suggest a proper formula, I need to understand the conditions better.

      So, assuming that "Expected Delivery" is column A and "Actual Delivery" is column B, the formula returns:

      "Late" if A2 is not blank and B2>A2, or if B2 is blank and A2 is greater than today;

      "On-time" if both A2 and B2 have dates and B2<=A2;

      No status (empty string) if A2 is blank "once it is not yet past the due date". How do we know this? What is the due date?

      The following formula works with the above logic, except that it does not check "once it is not yet past the due date":

      =IF(OR(AND(B2>A2, A2<>""), AND(B2="", A2>TODAY())), "Late", IF(AND(A2>=B2, A2<>"", B2<>""), "on-time", ""))

  23. Hi,

    I am trying to count the number of times multiple values appear in a cell across a row. e.g
    A1- 4,5,8
    B2 - 5, 31

    This would add up to 5, but i can't find a formula that can calculate this.

    Thanks in advance

  24. HI,
    I have 2 columns with multiple values. I want to count the unique No.of customer codes for each sales Agent. For instance, the value for Agent X shall be 2 (10 and 6).

    Sales Agent Customer code
    X 10
    X 10
    Y 25
    Y 5
    X 6
    Z 10

  25. Hi, I keep getting a value error for the following formula. Column E contains data from a validation list so I am not sure if this is affecting the outcome. Column K has words written as RED, GREEN, AMBER. Essentially I want to know how may meet the criteria of both Live and Red.

    The validation data is held in a worksheet entitled Sheet 3 - cell range D5-D9.

    =COUNTIFS('Programme Risks'!E4:E944,"Live",'Programme Risks'!K4:K920,"RED")

    Thanks in advance.

    1. Hi Ritchie,

      All ranges in COUNTIFS formulas must have the same number of rows and columns. So, I think changing the second range to K4:K944 should fix the problem.

  26. Many thanks Svetlana!

  27. Hello Svetlana,
    I have a list of parts with different end connections, some of those parts have more than one connection:
    0.5" NPT 1" NPT 0.25" NPT 0.75" NPT
    A X
    B X X X
    C X X X
    D X X X
    E X X X
    F X X X
    Can i use the CountIF function to tell which parts have the most common connections?
    Thanks
    Karim

  28. Thanks Svetlana,

    and if I wanted to use a cell reference instead of 60 do I just use "<C1" for instance?

  29. If i want to count "P" , "Late" and "Half Day" in same cell what will be the formula using countif formula.

    1. Hi Runu,

      To sum values with the OR logic, you need to add up 3 SUMIF functions, like in
      Example 4. COUNTIF formulas for non-contiguous ranges (OR logic)

  30. Hi

    I have 2 columns of data:

    1st column:
    Senior
    Senior
    Junior
    Senior
    Junior
    Senior

    2nd column:
    50
    60
    30
    70
    40
    50

    I want to count how many Seniors have a figure < 60 in column 2.

    The answer should be 2 - how can I do this please?

    1. Hi David,

      You can use a COUNTIFS formula similar to this:

      =COUNTIFS(A1:A100, "senior", B1:B100, "<60")

  31. Oops wrote it backwards.

    =AVERAGEIF(B1:B7,"Current",A1:A7)

  32. Average from a sum of cells.
    Column A Column B
    425 Current
    365 Current

    354 Not Current
    142 Not Current

    454 Current

    Average total of only the ones that state Current, leaving out the Not Current and blanks.

    1. Nevermind, found it.

      =AVERAGEIF(A1:A7,"Current",B1:B7)

      It was the middle that I was stumped on.

  33. Base on the data given, how can I get the desired output?
    Data:
    Box ID Sku Sku Sku Sku Locations
    A 123 123 456 123 Shop
    b 123 456 789 123 dock
    C 789 456 789 456 whse
    D 123 123 store1
    Needed result/output:
    Search sku 123 box ID locations records
    a shop 3
    b dock 2
    d store1 2

  34. Box ID Sku Sku Sku Sku Locations
    A 123 123 456 123 Shop
    b 123 456 789 123 dock
    C 789 456 789 456 whse
    D 123 123 store1

    Search sku 123 box ID locations records
    a shop 3
    b dock 2
    d store1 2

  35. 1st 2nd 3rd 6th 7th 8th
    7:59am None
    Scheduled Closed 8:02am No Show 8:03am
    I need a formula to only count the times which are equal to or greater than 8:00am. i need it to only count the times.

    1. Hi Pam,

      =COUNTIF(A1:D100, ">="&TIMEVALUE("8:00 am"))

      Where A1:D100 is your range.

  36. I'm trying to use a COUNTIF formula, where the criteria is a cell reference to a formula result.

    Is there anyway the COUNTIF formula will pick up the formula result value ?

    ---------------------
    A,B, C
    1)7,1,"=IF(A1>0,A1+B1"

    Result in "C1" will be "8"

    Now I would like to use value "8" as "criteria" in the COUNTIF function.

    =COUNTIF($AA$1:AA$100,"=C1")

    But it won't pick up the "8" value but returns "0"

    Thanks in advance...

    1. Hi Mark,

      When you enclose cell references in quotes, Excel interprets them as text strings. Once you remove "", your formula will work fine:
      =COUNTIF($AA$1:$AA$100, $C$1)

      You can also put it like =COUNTIF($A$1:A$100, "="&C1)

  37. Thanks worked great for me!!

  38. hi! I have a column 3400 reference value (persons id) and want to count how many times listed in an other column (trips in taxi). can you help me? thanks

    1. Hi Paula,

      Amusing that your persons id column contains unique values only, you can use a formula similar to this:

      =COUNTIF($B$2:$B$1000, $A2)

      Where A is the id column (row 2 is the first row with data) and B is the other column (trips in taxi).

  39. Hi, I'm trying to calculate the following.

    IF a cell in B2:B19 contains the word "Food" THAN I want the numbers in corresponding cells in E2:E19 to be added up.

    For example B2 and B5 contain the word "Food". Their corresponding cells E2 and E5 contain "E2: 8 and E5: 10", the total of the formula would be 18.

    The B column contains various Types in text and the E column contains different amounts of that types in numbers. I want to see the totals of every type without having to manually choose E2+E5 etc.

    I hope this makes sense.

    1. I found the answer

      =SUMIF(B:B,"Food", E:E)

  40. I have a problem with a "countifs" statement and I was wondering if anyone can help.

    One of my columns has cells where the content is <=5 as the value and it isn't a calculation. I want my countif to count how many instances of those, but when I put it in my countif calculation it sees the <= as part of the calculation and produces the wrong results. Is there any way to see <=5 as a value instead of a calc in that cell?

    Any help is appreciated.

    Thanks,
    Sharon

    1. Hi Sharon,

      I cannot figure out a way with COUNTIFS either. But you can use the following array formula instead:
      =SUM(--(A1:A100="<=5"))

      Please remember to press Ctrl+Shift+Enter to enter it correctly.

  41. Excellent information dear...!
    This information made my day.
    Once again, thanks a lot.

  42. Hi,

    i want to count if the column contains a date(unconditioned)

  43. found the answer. I need to test criteria on each and sum:
    =COUNTIFS(date1,text)+COUNTIFS(date2,text)+...+COUNTIFS(daten,text)

  44. Evening Svetlana,
    I have used your posts many a time to gain answers for my questions and until now was always able to find an answer. I have an issue that I cannot figure out. What I am looking for is a way to count the number of records that meet multiple criteria. My issues comes when adding in the multiple fields. I have a project list with Start dates, Team name, Department and Type of project. Above that I have a list of the start and stops for each week of the year.
    What I am trying to do is count the records where the start of the project is between the start\stop date for the given weeks but only when the project team is a given name (Blue, or Green) or the Department is a given name (SRT). The fields are exclusive but complimentary so I need to add an "or" statement but cannot get it to work.

    1. Hi Thomas,

      To count with the OR logic, you need to add several SUMIF or SUMIFS functions, for example:

      =COUNTIFS(A2:A10, ">=start date", A2:A10, "<=end date", B2:B10, "team1",) + =COUNTIFS(A2:A10, ">=start date", A2:A10, "<=end date", B2:B10, "team2",)...

  45. My example was cut off, let me try again...

    If Text = "Major"
    and Date GE lowerLimitDate
    and Date LE upperLimitDate then count it.

    Henry

    1. Hi Henry,

      You can use a formula similar to this:

      =COUNTIFS(Table1[text], "Major", Table1[date], ">4/10/2015", Table1[date], "<4/20/2015")

      Where [text] is your Text column, [date] - column with dates, 4/10/2015 is lowerLimitDate and 4/20/2015 is upperLimitDate.

  46. Great article; maybe you can help me. I have a named table with over two dozen date columns and one column of text.

    I want to count the number of dates within a date range and that have a specific text value

    date1 date2 ... date26 Text

    Logically this would be:

    If Text = "Major" and Date = upperLimitDate then count it.

    I can't get COUNTIFS to do this.

  47. PLZ REPLY FAST

  48. i have a sheet in which a column shows percentage of attendance i have to provide the formula for next column to give the values for the percentage..for example
    if the student have percentage in between 75 to 80 i have to give 01 marks and 81 to 85 then 02 marks ,86 to 90 03 marks etc.the how to write formula?

  49. Is there a way to combine a COUNTIF with a MIN function? I have three different amounts for each client, and I need a count for how many times the first value was the least of the 3, how many times the second value was the least of the 3, and how many times the third value was the least of the 3. Any help is greatly appreciated.

  50. Hi There,

    I am not able to find the right countif formula to count "AA" in next column with reference to another column!! For example in Column 1 I have different Cable types and in next four columns whether is applicable or not I had mentioned with AA, BB, CC, DD. Here I have to count how many "AA" are available against one type of Cable. Could any one please help me out??

    1. Hi Kardon,

      If column 1 (let's say column A) contains unique cable types only, i.e. a single record for a certain type, you can use the following formula:
      =COUNTIF(B2:F2, "AA")

      Where columns B - F contain AA, BB, CC, DD. The formula counts the number of AA in each row.

      If you have multiple instances of the same cable type in column A, then the best solution I can come up with is this lengthy formula:

      =COUNTIFS(A2:A8, "cable1",B2:B8, "AA") + COUNTIFS(A2:A8, "cable1",C2:C8, "AA") + COUNTIFS(A2:A8, "cable1",D2:D8, "AA") + COUNTIFS(A2:A8, "cable1",E2:E8, "AA") + COUNTIFS(A2:A8, "cable1",F2:F8, "AA")

      Where "cable1" in the cable type, 2 is the first and 8 is the last row with data.

Post a comment



Thank you for your comment!
When posting a question, please be very clear and concise. This will help us provide a quick and relevant solution to
your query. We cannot guarantee that we will answer every question, but we'll do our best :)