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 47. Total comments: 2055

  1. Hi.

    I hope to get help from you.

    I have in one sheet a serial number of products. In another sheet, it shows the dates to when customers called and complained about a product. What I would like to achieve is that I would like to know how many complaints a specific product received in a 7 days, 30 days and 90 days period using the product serial number as reference.

    Thank You for any response.

  2. Hi Svetlana,

    I can't seem to get a simple formula to work:

    I have a grid spanning 31 columns wide and 5 rows deep. In any one of the cells I can have either, "M", "H", "S", "P" or nothing.

    The 5th row has to total up how many times in each of the 31 columns how many of each of the letters are shown and add them up. I'm currently trying to use this one in row 5 of column c for example:

    =COUNTIFS(C5:C9,"P",C5:C9,"h",C5:C9,"s",C5:C9,"m")

    The box just returns 0 even when there are matching values.

    Can you help?!

    1. I literally solved it straight after posting this - typical! Took me two hours to admit defeat and post this question, then solved it almost immediately afterwards!

      I used this to fix it (I wasn't adding the values together!):

      =COUNTIFS(B5:B9,"P") + COUNTIFS(B5:B9,"h") + COUNTIFS(B5:B9,"s") + COUNTIFS(B5:B9,"m")

      Thanks for providing the inspiration to sort it!

      1. Thank you

  3. Good afternoon,

    If using =COUNTIF(C5:C21,"X")/ROWS(C5:C21) to get the percentage of what X equals.

    How do I edit this formula to know the percentage of what X equals if I need to add multiple columns and rows together?
    Columns C & D, Rows C5:C21 & D5:D21
    Columns C & E, Rows C5:C21 & E5:E21
    Columns D & E, Rows D5:D21 & E5:E21

    Thank you,

    Kelly

    1. Kelly,
      Did you ever figure out this formula? I am trying to do the exact same thing and I cannot get it.

      If you did and could share it I would be much appreciative.

      Thanks!

  4. m from a hospital background, i do need to use excel a lot to complete ma audits and various reports. m having a problem with my audit data. there are around 18 columns and about 500 rows, data validation has been applied, which gives me 3 options for each cell (yes no and NA). It is similar to your example of "COUNTIFS for text values:: counting who passed all the subjects. but in ma sheet there are three options, out of these i want to count yes and NA together and neglect no. i tried number of formulas but couldnt get the right one. atlast i counted number of "no" first in a row then subtracting it from total which gives me the value of number of "yes and NA" in same. But i was wondering if there is a possibility of counting two texts together in a single row.

    1. Hi JOLLY,

      You can add up the results of 2 COUNTIF functions, like this:

      =COUNTIF(A1:F500, "yes") + COUNTIF(A1:F500, "na")

  5. Countifs with multiple criteria as is not showing correct input
    Countifs(A:A,"Jan",B:B,"User1",B:B,"User2")
    result showing as 0

  6. dear mam,
    i have the following data in sheet
    A B C D E
    1 SL RM RM/SL JY/RM SL
    2 JY SL SL RM/SL RM
    3 RM RM/SL JY/RM JY SL
    i want to count "SL" or any other string combine with other. which countif cirteria should i use?

    1. Hi TEJASWINI,

      You can use a usual COUNTIF formula like this:
      =COUNTIF(A2:E4, "SL")

  7. Thanks the countifs definition and example really helped me resolve a calculation issue in one of the formulas I was using.

  8. Having a problem figuring out why a countifs formula doesn't work. I have a file that has several types of status closings in it - Verified; Verified-Paid; Verified Denied; Canceled; Taken; Assigned.

    Based on the client I want to count the number of any trip status that is {Verified* or Taken* or Assigned*}

    And further has the Level of Service that is any of . . .

    =SUM(COUNTIFS(Table1[Broker Client],"VA Client Health",Table1[Status],{"verifi*","Taken*","assign*"},Table1[Trip Level of Service],{"ambu*","Lodg*","Meal*","special*","Mass*"}))

    What am I missing with the Wildcards and {}. It's a 145000 + row file

  9. I have a formula that is working to get my answer, but the problem is I need to use that answer in another formula and that isn't working. Any help on that?

    1st Formula: =IF(COUNTIF(F:F,"*Corr*"),"1",)

    2nd Formula that need to be able to count the "1" in the first formula. : =SUMPRODUCT(--('Raw Data'!C:C=C4),--('Raw Data'!H:H=1))

  10. Hi,

    I am trying to count how many consecutive days each employee works in a given date range. Here is how my spreadsheet is set up:

    A1 = Title Name
    A2 to A100 = Employee Names (an employee name may be lkisted 20 or more times in a row and then the next employee's name - in alphabetical order)

    C1 = Date Worked Title
    C2 to C100 = Dates (consecutive dates)

    H1 = Hours Worked Title
    H2 to H100 = Hours worked each day

    So, I am trying to find for each employee, what is the maximum days in a row (consecutive days) each employee worked.

    Thanks in advance.

  11. Good Morning!
    This tutorial was very helpful. I am having an issue with some dates in the formula:
    =COUNTIFS(tblEvents[Date of Request],">=6/15/2015",tblEvents[Date of Request],"=J1",tblEvents[Date of Request],"<=J2")

    Thank you! Tanya

  12. Howdy,
    I’m trying to figure out how (or) if I can apply countifs to my spreadsheet. What I have going:
    In Column “I” I have Panel ID i.e. C3D
    In Column “J” I have # of panels (“1” per line item currently)
    Column “L” I have panel ID again
    And “M” I have QTY
    My thought process behind this so far, is when I receive a trucking invoice, I receive, i.e. 20 panels of C3D. Well, currently I have to enter C3D 20 times with a “1” next to each in # of panels to get the QTY in “M” to count it. What I want to do here is be able to enter “20” in # of panels in “J” for ID C3D in “I” and have it say, on row 9 in column J is C3D, and for that entry is 20 of them and count 20 for C3D. Say tomorrow I can 3 more C3D. Next row in row 10, C3D with 3 and the countifs not stop at the first one with just 20, but keep going and say, hey, 3 more for a total of 23.
    Any help would be greatly appreciated!

  13. No accident type A B C R
    1 A Total-... ... ... ...
    2 B
    3 B
    4 R
    5 B
    6 A
    7 C
    accident type can filter.I want to get the total for each accident type for long data sheet. Thanx a lot for this service

  14. Hi,

    15-Jun MDM
    16-Jun PTP
    17-Jun DTDE
    18-Jun MDM
    19-Jun PTP
    20-Jun QTC
    15-Jun RTR

    Above is the one which is there in my excel.

    Am using formula as to find between dates from 15th to 19th

    =COUNTIF(H2:H9,">=6/15/2015")-COUNTIF(H2:H9,">6/19/2015")

    Along with this, I would like to add condition which Matches I column too, say if I need to see between the date rang what are all there as "MDM", in this example it should return a count as 2.

    Kindly let me now how to add the condition.

    1. hi Murugesh, you might want to try this. was having the same problem but manage to solve it like this. reason for using DATE() was because, they are comparing date serial with text before. but since you converted your dateText to the same comparing format, it would works. hope it works for you too! :)

      =COUNTIFS(H2:H9,">="&DATE(2015,6,15),H2:H9,"<="&DATE(2015,6,19),I2:I9,"MDM")

  15. Hi,
    I want a formula that counts 2 or more rows like AND gate logic.
    Example:
    one row is having "pens" and another row having "RED color".
    I want how many red color pens are there.

    Thanks in advvance for ur assistance

    1. Hi!

      Supposing that Column a is "pens" and column B is color, you can use the following COUNTIFS function:

      =COUNTIFS(A1:A100, "pens", B1:B100, "red")

  16. How to Solve this.
    In cell B5, use the COUNT function to calculate the total number of students in the class.
    where A17:A52 contains student IDs.e.g,393-411-8,393-440-4
    etc

    you dont have to ise COUNTA,COUNTIF,COUNTBLANK etc functions.only use COUNT function

  17. Hi, I'm trying to count the number of items between two dates which meet a criteria (A3). So far i have got this, which seems to be only giving the results which are greater than 1 May as opposed to between 1 May and 31 May:

    =COUNTIFS('DRAFT AUDIT RESULTS REGISTER'!$B$3:$B$100,A3,'DRAFT AUDIT RESULTS REGISTER'!$A$3:$A$100,">=1/05/2015")*AND(COUNTIF('DRAFT AUDIT RESULTS REGISTER'!$A$3:$A$100,"<=31/05/2015"))

  18. How do i count a row based on specific column data. Like count the number of cells with numbers and exclude Fridays from the column.

    well simple way is this =COUNT(E22:AI22)-COUNT(I22,P22,W22,AD22)

    but i want it more automated where the COUNT(I22,P22,W22,AD22)are the Fridays and COUNT(E22:AI22) is the cells with numbers

  19. Hi Svetlana,
    Hoping you can help with my data comparison.
    I have two sets of timesheet data (3 cols - project, person and hours) and i have managed to find ones where all three match between the sets. what i am trying to find out is where the Project and person match but the hours have changed... i want to find out by how much the hours have changed

    So if in Set A - person x has done y hrs against Project 1
    But in Set B - Person x has done Z hrs against project 1.

    i would like the formula to tell me that Person X's hours against project 1 has changed by (y-z)hrs

    thank you ... this would save me hours of manual work!

    thanks
    meena

  20. Hi Svetlana.

    I have a table and the rows contain either "TRUE" or "FALSE" in each cell.

    Is it possible to count how many times have "True" happened 3 in a row on each roll? e.g TRUE TRUE TRUE

    So at the following example, "True True True" happens 1 time only:

    FALSE FALSE FALSE TRUE FALSE FALSE TRUE TRUE TRUE FALSE

    and what if I have 4 True happened in a row:

    FALSE TRUE TRUE TRUE TRUE FALSE TRUE FALSE

    Will Excel read "True True True True" as 2 times?

    Thank you!

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

  22. 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.

  23. 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.

  24. 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

  25. 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"))

  26. 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

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

  28. 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)

  29. 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,"")

  30. 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.

  31. 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

  32. 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

  33. 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

  34. 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!!

  35. 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")

  36. 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

  37. 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.

  38. 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.

  39. 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

  40. 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

  41. 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.

  42. 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", ""))

  43. 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

  44. 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

  45. 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.

  46. Many thanks Svetlana!

  47. 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

  48. Thanks Svetlana,

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

  49. 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)

  50. 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")

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 :)