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

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

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

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

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

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

  6. Many thanks Svetlana!

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

  8. Thanks Svetlana,

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

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

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

  11. Oops wrote it backwards.

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

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

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

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

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

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

  17. Thanks worked great for me!!

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

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

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

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

  22. Hi,

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

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

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

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

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

  27. PLZ REPLY FAST

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

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

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

  31. Hi There

    I was wondering if it was possible to have 3 COUNTIFS formulas in one cell?

    1. Hi Jake,

      It is not possible to have several different formulas in one cell. However, you can put 3 different conditions in 1 COUNTIFS formula.

  32. I'll explain what I have:
    I created color function to count cells with certain color and now I want to count celles that has value and certain color at the same time

  33. hi, i need your help:
    can i incloCan I include function within the COUNTIFS function like the following example:
    =COUNTIFS(D4:AH4,"COUNTA(D4:AH4)")
    It does not give me correct answer. Please help me.

    thank you.

    1. Hi Ghazi,

      If you are looking for a way to count non-blank cells in D4:AH4, you can use the following formula instead:
      =COUNTIF(D4:AH4,"<>"&"")

  34. Hello again Svetlana,

    Apologies. I neglected to type the words "Inside" and "Outside" in full within the formula in my last post. Sorry!

    Regards,
    Leela.

  35. Hello Svetlana,

    I'm not sure if I can use COUNTIF/COUNTIFS for my following query. Perhaps the solution may be SUMPRODUCT as I have tried. I'll wait for your advice.

    I have a column (A) going down 1000 rows. Each cell has either "Inside" or "Outside" typed in them. The next column (B) has dates in each cell (also going down 1000 rows). I need to search Column A and if the cells contain the word "Inside" or the word "Outside", total the number of dates in Column B that are less than or equal to(<=) Today(). There will occaisionally be blank cells in Column B. I have come up with this formula but it still counts the blank cells in Column B :-

    =IF(ISBLANK(A:B),"",SUMPRODUCT((B:B<=TODAY())*(A:A="In")+(B:B<=TODAY())*(A:A="Out")))

    Greatly appreciate any help.

    Regards,
    Leela.

  36. Long story short, thank you, Svetlana, for this post! Your explanation and examples using COUNTIFS were just what the doctor ordered!!

  37. Hello!
    I have two columns I have to match. I thouught I can use COUNTIF function to calculate the frequencies from column B matching it to a value in column C (as there are more then one values in column C, so I have to choose to calculate the frequencies of each of them separately). How do I do that? I tried all the combinations but I don't think I understood the above explaination correctly.

  38. Hi,

    I have 3 columns containing the following info regarding subscription period to a website: User, Service Start Date, and Service End Date, with the dates ranging from 2013 to 2016. I'm having some trouble using both COUNTIF and COUNTIFS to get how many Users (A2:A617) are active on a particular period (e.g. Jan-2013 has 21 active subscribers, Feb-2013 has 24, etc.).
    I would really appreciate your help.
    Thank you.

  39. Hello,

    I have two sheets. One is called "Rollup" and the other is called "Data". On the "Rollup" sheet, I am using column "E" for my formula and what I'm trying to do is count anytime whenever the name in column "B" of the "Rollup" sheet appears in D2:D39228 of the "Data" sheet. So, on the "Rollup" sheet for example, cell E2 will have a COUNTIF formula that asks how many times the name in B2 of "Rollup" sheet appears in D2:D39228 of the "Data" sheet. Does that make sense?

  40. Hi there. I need help with Countif. So I have two columns, both are dates.

    1. Target Award Date
    2. Actual Award Date

    I need to count how many actual award dates were before the target.

    For example.
    Target Award Date is 2/10/2015
    Actual Award Date is 2/8/2015
    This should be counted

    If the Target Award Date is 2/11/15 and actual award Date is 2/15/2015, then it wouldnt be counted.

  41. Part code Qty
    1 12 Part number '1' total-
    2 85 Part number '2' total-
    1 47 Part number '3' total-
    4 69 Part number '4' total-
    3 32
    1 12
    4 45
    2 12
    3 36
    1 58
    4 51
    2 78

    Please help in summing the total of each part number...

  42. i have a range of data from A2:A308 i want to place a criteria that if the data in the range falls less than 8 it should display primary if greater than equal to 8 and less than 13 it should display secondary and if greater than equal to 13 it should display tertiary

    1. Hi Zeta,

      I think this will help...
      =IF($A1=13,"Tertiary","Secondry"))

      1. =IF($A1=13,"Tertiary","Secondry"))

  43. i have a problem
    that is i have a range of data from A2:A308 i want to place a criteria that if the data in the range falls =8 and =13 it should display tertiary

  44. Greetings from South Africa!

    I am creating a database to count four different types of clinical personnel receiving training on medical male circumcision. Information will produce two basic spreadsheets. One counts the number of trainees per training type (8) and segregating each clinical personnel type per month (1,350 cells). The other segregates each clinical personnel type and training received per province (state) (9,350 cells) Thanks to information from your website I created formulas that are working, but my question is how can I copy and paste the formulas that automatically change the month I want to capture. An example is below where 01 represents January. How can I copy and paste the formula setting the month to change automatically to 02, 03, etc?
    =COUNTIFS($A$25:$A$5000;"01";$G$25:$G$5000;"D";$I$25:$I$5000;"S";$L$25:$L$5000;"EC"&"")

    Thousands of Thank yous if you can help.

  45. Hi,

    A B E F
    1 Santosh 10 Raj
    2 Raj 5 Sajan
    3 Sajan 8 Ankit
    4 Ranjan 9 Tara
    5 Sameer 10
    6 Priyanka 4
    7 Ankit 8
    8 Tara 6

    in the above spread sheet there is some names from A1 to A8 consequent the figures on B1 to B8,

    My question is Cell E1,2,3,4 i mentioned few names in jumbling way ok, if those names are in the list of A1 to A8 then i want the consequent figure (which mentioned at B1 to B8) to be visible @ F, ok

    guide me with the formula...............

    1. Here you go...

      if you want name with consequent figure..
      =IF(ISERROR(VLOOKUP($C2,$A$2:$A$9,1,0)),"",$C2&VLOOKUP($C2,$A$2:$B$9,2,0))

      If you only want the figure then...
      =IF(ISERROR(VLOOKUP($C2,$A$2:$A$9,1,0)),"",VLOOKUP($C2,$A$2:$B$9,2,0))

  46. Hi. I have an excel spreadsheet with first names in column A and last names in column B and other information in columns C and on. I access and change this file daily. I need to know when a specific person shows up 6 or more times and then I have to move the data to another sheet. I already have it sorted by last name, column B, but I still have to go through and count each individual name to make sure there are 5 or less or I have to move them. Is there a way to use COUNTIF(S) to let me know if there are names that appear more than 5 times and maybe even what the names are? I have to go through this process every day and it would save me a lot of time looking through the 800 rows.

  47. Hello Svetlana, I really hope there is an answer to this I've tried several ways but it doesn't seem to work. Assuming I have data in A1:A3 and the data totals are in A4 & A5. The data that needs to be added across for example are 2/2, 3/2, 4/1; the left number is the attendance for adults and right side are the children. The data total for A4 would = 9 and A5 = 5. Does it matter if the data in one cell is seperated by either symbol? Ex. 2/2 or 2:2 or 2+2? I need HELP how to add the data across but keeping left side total from right side. Is there a simple solution?

  48. Recipt Credit
    Cash Book Bank

    564 914308
    30,000 30000
    30000 4654
    43660 30000
    1245247 19344
    30000 465654

    I want to know matching values in col a & b
    e.g there are 2 values (30000) in col b
    it should show corresponding 2 values in col A & not 3
    values as appeared in col a

  49. Recipt Credit
    Cash Book Bank

    564 914308
    30,000 30000
    30000 4654
    43660 30000
    1245247 19344
    30000 465654

  50. ok i am trying to make spread sheet that tracks the units average score for said events, but I don't wont to enclude the certain personal that are on a profile preventing them to take a certain event.

    So I guess the question is there a way to put an AVERAGE Formula and a COUNTIF Formula in the smae cell, in order track all this type of information or am I too far out in Left Field this function is impossible?

    Thanks for your time and answer/assisstance with this issue I have.

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