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

  1. I want to search an array where one value is an exact match, and the second value falls within a range (specified by two columns – an upper and a lower bound)

  2. Hi Svetlana,

    I am attempting to count rows that contain a specific piece of text in the C column as well as a specific number in the I column. The formula I am attempting to use is:

    =COUNTIFS(Sheet9!C2:C163,"="&B3,Sheet9!I3:I163,"=7")

    The formula returns a #VALUE! error but I am unable to locate it. Would you please point out what I am doing wrong?

    Thanks.

  3. Hi team,

    I had a query about countif and sum if and I have sent an email to the support email ID. I just want to know how long does it normally take to get a response.

    cheers

  4. wow thanks, i know now how to use count-if

  5. Is there a way to calculate the amount of hours in the same cell if I inputted 8am-4pm? the goal is to use one row to input the time as shown above and a row to show the total amount of hours. in this case would be 8.

  6. Hello

    I am trying to use a countifs combined such as shown below. What I am am trying to do is with to check each of the cells referenced in the range to see if the text in the criteria is present. Overall intent is to determine a percentage of compliance. So in this case if each of the cells referenced are determined to be met in the criteria check then the cell where this formula would be 100%. If only part or none of the criteria are met then the cell would be the percentage based on the counts. I have tried adding an If before the count but it seems something is wrong.

    =(COUNTIFS(BA5,"2008 or Above")+COUNTIFS(BA5,"Not Applicable")+COUNTIFS(BC5,"Has Maintenance",BC5,"Not Applicable")+COUNTIFS(BR5,"All Physical Servers Have Maintenance",BR5,"Not Applicable"))

    thanks for your time. Enrico

  7. Hi Svetlana,

    I am having a problem with countif function. I want to test a column data with dates and count them by the weekdays. Here is what I wanted to do, R18=COUNTIF(B3:B12,WEEKDAY(B3,1)=Q18). It is not working.
    How to count a column data by testing those datas with another function(Weekday)?

  8. 2-2-2= 6
    2-2-2= 6
    6-4-6= 16
    4-4-8= 16
    2-4-2= 8
    4-4-4-2= 14
    how ca we add these items and get sum

    1. If you simply want to some cells row-by-row, you can use a usual SUM formula, e.g. =SUM(A1:C3)

  9. Hello,
    I want to count the number of concentration values in a specific range (4,000) for a subject list. However,each subject (listed by patient ID) can have 2-5 concentrations (each listed in a separate row), and some are in more than 1 range (e.g. low and high). I would want to group by patient ID, keeping all their samples together, but sort the data into those patients with all samples being in the low range, all in the high range, all in the middle range, and then another group with those that are mixed ranges.

    Any help you could offer would be greatly appreciated.

  10. how can i count 2 categories in same raw ex n , b
    n b n b n b b b b b n b n b n b n b n b

  11. Svetlana, I've got a workbook where I'm tracking attendance at various classes. Each class and attendance roster is a separate tab. I've got an employee summary tab where I've set it up to count the number of times each employee appears across the various tabs. I'm using this formula =SUMPRODUCT(COUNTIF(INDIRECT("'"&$A$2:$A$15&"'!A1:M200")A29)) for that and it's very successful. A2:A15 are the tab names, A1:M200 the range on each tab to search and A29 is the employee name. So far so good.

    Now I need to do a similar count, but only when the class is required by the person's title. I had to set up the names of the various tabs (see above) in order to make the previous formula worked. So I just made it a grid by adding titles across the top and indicating which class was required for each title. I'm just lost now on how to make that work with a formula. Any help is appreciated.

  12. I'm trying to create a countif formula to avoid duplicate records. Two of my headings are "Name" & "Date" my goal is to NOT enter a name using the same date more than once. Can you help?

  13. Hi Svetlana -

    I was wondering if you could help me on how I can use Countif or Countifs to check a list/colmun of different words, tell me how many times it appears in a search of about 300 rows. I have about 70 different words to search in it would be time consuming if I just simply worked one at a time using =countif(A1: LP12,"Different Words to Look up").

    I believe there is a formula that I can just either drag and use to look all at onces.

    Thanks,

    Javier

    1. Hi Javier,

      If you have a list of those 70 words in some column, you can reference the first cell in the formula, say $A13, and then copy the formula down to other cells:
      =COUNTIF($A$1:$LP$12, $A13)

  14. Below is my formula, it is counting everything in the first () and not the second. Please help.

    =COUNTIFS('513TH BYNAME'!G2:G1500,"09L5",'513TH BYNAME'!H2:H1500,"OO")+ COUNTIFS('513TH BYNAME'!I2:I1501,"9J,9Y,9T,9V,9R,9Q",'513TH BYNAME'!K2:K1501,"*2015")

    Does not count the second COUNTIFS('513TH BYNAME'!I2:I1501,"9J,9Y,9T,9V,9R,9Q",'513TH BYNAME'!K2:K1501,"*2015")

  15. Hi,

    I want to count the number of cells from "today's date" to a specific charater, lets say S.

    For example: If todays date where 15:th of july and I have my sheet like this:

    Dates:
    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
    S P T L L

    I want it to count the number of cells, regardless if the cells are blank or have a different character(P,T or L) from 15th of july until it finds the first S, thus 15-3=12.

    Hope you can help.

    Thanks

    1. Somehting went wrong when I sent the question as seen above, it would be: 15-1=14.

      Please help

  16. Hi there,

    I have to get 2 columns of data from a data sheet.

    Basicly Column X is a name and Column Y is an answer of one of six results.

    While Column X will remain the same I need to see how many of each of the results appear for Coloumn y of the 6 criteria.

    I used =COUNTIFS(A1:A941, "JOHN", C1:C941, "CLOSED")

    But it wont tell me how many of the columns under Johns name are closed

    Can you help?

  17. Hi Svetlana,

    I'm using excel mac and I'm trying to countif a date range and using a separate worksheet the name of the worksheet is KIDS and the column in that worksheet is R. Please where am I going wrong, below is an example;

    =COUNTIFS(KIDS!R:R, ">01/07/2015", KIDS!R:R, "<31/07/2015")

    Thanks heaps :)

  18. I am working with excel to draw up characters in columns consisting of random alphanumeric combinations. For ex: TRG, 0RG, 12TT, in column organization. I want to list the number of each individual character and how many times the character appears within each column. .. IE: 0=1, R=2, T=3. The countif function completely works for alphabet characters, but not for numeric when next to alpha.

    The 0 numeric when beside an alphabet character is simply not recognized. I've attempted some * with no luck..I'll keep reading could you please provide some insight?

    1. Hi Andrea,

      You can use the following array formula (Remember to press Ctrl+Shift+Enter to enter it correctly):

      =SUM((LEN(A1:A100) - LEN(SUBSTITUTE(A1:A100, 0, ""))))

      Where 0 is the digit you want to count.

      Instead of supplying a numeric value in the formula, you can place it in some other cell, then the formula will be slightly different, as in the following example: Array formula to count any given character in a range.

  19. Svetlana Cheusheva,hope yo helping me,thanks

  20. YES NO
    x
    x
    x
    100%

    hi,how can I automate, such that when is placed in a NO column then the percentage reduces eg

    YES NO
    x
    x
    x
    67%

    regards

  21. Outlet type: A, B, C, D

    Expected Product range by outlet type

    A - 20g,30g,170g,410g,400g tin,400g pouch,uht fc,uht lf
    B - 20g,30g,170g,410g,400g tin,400g pouch
    C - 20g,30g,170g,410g
    D - 20g,30g,170g

    Product presence report (Yes means available while No means not available)
    Peak 170g - No
    peak 410g - Yes
    peak 30g - Yes
    peak 20g - Yes
    peak 400g Tin - No
    Peak 400g P - No
    Peak 900g - No
    Peak uht fc - No
    Peak uht lc - No

    Hi Svetlana, i have above merchandizing report data. Based on the outlet type and the lists of products expected there and the product presence report, i want a formula that will count and return the number of products present in the outlet by considering the type of outlet (A,B,C,D). Thanks

    1. Dear Svetlana,

      Still waiting please, i believe you are working on my request. Thanks

  22. i have got data of employees for a mining company. i want to count those that appear on the breakfast, lunch and dinner differently. how can i do that?
    thanks

    1. Hi Abraham,

      If you can provide more details about your data structure, we will try to make a formula.

  23. hi,
    i have got a big data of employees working for a mining comapany, i want to know the number of employees that come for breakfast, lunch and dinner differently. how can i do that?
    thanks

  24. Hello. I’m trying to count unique text values in column A that meet date criteria in column G as determined by one cell (H158160) that contains a drop down list of dates selected by users. The intention is for them to be able to select the date from the list and see the count of account numbers, the sum of units sold, and the sum of revenue. I’ve got all of the formulas working except for the count of account numbers, because I’m having trouble with the COUNTIFS formula. I’ve been able to count unique values using the array formula {=SUM(1/COUNTIF(A2:A796,A2:A796)}, but I don’t know how to set these multiple criteria. Hopefully you can help. Thanks in advance!

  25. I am trying to count the number of people who have done an intervention by the place from which they come from. I am taking this information from another sheet. The thing is they have done up to four interventions and the intervention columns are not in direct order of one another. So I am trying to count the number of people say playing football which could be in four columns by the place the live.

    I have tried =COUNTIFS('USER SHEET'!AC2:AC10000,Intervention!D3,'USER SHEET'!B2:B10000,Intervention!C4,('USER SHEET'!AF2:AF10000,Intervention!D3,'USER SHEET'!B2:B10000,Intervention!C4,('USER SHEET'!AI2:AI10000,Intervention!D3,'USER SHEET'!B2:B10000,Intervention!C4,('USER SHEET'!AL2:AL10000,Intervention!D3,'USER SHEET'!B2:B10000,Intervention!C4))))

  26. How chose two fromm three number the best.
    Excample:
    A: 30
    B: 20
    C: 10
    Two the best 30+20=50

  27. I am trying to use a count function, but struggling to get the formula to work.

    I have an area that will be filled in with different dates. On a separate sheet I have a running date column. I want to count how many boxes have a certain date in it.

    =COUNTIF(Sheet3!$C$23:$EF$34,"=14/8")

    This is the formula I'm currently using, which works fine, but I cant drag it down. I've tried doing the alternative:

    =COUNTIF(Sheet3!$C$23:$EF$34,"=B8")

    (B8 is where the 14th August is located). This does not work.

    Please help.

    Thanks
    Craig

    1. JUST REMOVE THE $ SIGN AND DRAG DOWN

  28. Good Morning,

    I am so thankful I found this site.
    I am looking for a simple formula to find all 4s in column b, that has a code of X3,Z1, and Y9 in column E, PLUS all 5s in column B, that have blanks in column D, with codes of X3, Z1 and Y9 in column E.
    Can this be done? If not, thats fine, I will complete it the same as always.
    I appreciate all your help.

    Rick

    A B C D E

    5659 4 91B 91B2 Z1
    2935 4 68C 68C2 Z1
    6572 4 92W 92W2 Z1
    8675 4 91D 91D2 Z1
    7627 5 12B 12B2 Z1
    7450 5 19D 19D2 X3
    9171 5 36B 36B2 Z1
    3503 5 11B 11B2 Z1
    5759 5 36B 36B2 X3
    5062 5 15D 15D2 Z1
    9088 4 91E Y9
    1665 4 68W 68W2 x1
    7212 4 68W 68W2 x1
    4539 4 15U 15U2 Z1
    2579 4 74D 74D2 Z1
    8052 5 14H X3
    2423 5 15U X3
    5228 5 12P Z1
    9080 5 19D Z1
    9076 5 11B x1
    691 5 74D x1
    3504 5 31D x1
    8594 5 14E x1
    919 5 11B x1
    4518 5 11B X3

  29. Hi!

    I have two columns (all text). The first column is a list of names (could be repeated) and the second column is a list of factors (i.e. "ontime", "late", etc.). I want to know how many times a certain name (from the first column) hits each factor from the second column. Hopefully this is clear.

    Thank you!

    1. Hi Again,

      Please disregard. I used a SUMPRODUCT formula which worked like a charm!

      1. Hi Melissa. How did you get this to work?

  30. Hi I am trying to use a countifs formula for the following situation:
    I have multiple staff and I want to get a tally of how many times each staff puts in overtime for each reason for overtime.
    I have been successful with this but I want to take it to the next level and find out the total amount of time corresponding to each reason for each staff member. So the formula is referring to a separate tab in excel and basically saying that if B4:B30 says "X" and c4:c30 says "Y" I want the value of D4:D30 that corresponds to this condition to show in the cell. Is this possible?

    1. Hi Kim,

      Let me check if my understanding of the task is correct. so, if B4 says "x" and C4 says "y", you want to pull the value from D4. If so, you can enter the following formula in row 4 and then copy it down to other cells in the column:

      =IF(AND(B4="x", C4="y"), D4, "")

      If you want to sum the numbers in D4:D30 that correspond to those conditions, then you can use the following SUMIFS formula:

      =SUMIFS(D4:D30, B4:B30, "x", C4:C30, "y")

  31. Hi,

    Do the different parts of the countif formula all have to be contained within the same worksheet?

    I have created a report which has data on one tab, and a query form on a second tab. The countif formula is looking at concatenated fields which I want it to return a value of the number of occurrences of a selected concatenated value (such as contract number and month). I am getting a zero when using the countif formula which uses the data as the first part of the countif, but the second part of the countif formula is from a cell in my query form.

    If I do a countif where both table and criteria are on the same tab, I get the value I'm expecting.

    Thanks,
    Paul

  32. Hi,
    I need to use the COUNTIFS to count ID#’s that are between specific dates (for example: 6/22/2015 -6/28/2015; 6/29/2015-7/5/15; 7/6/15-7/12/15) but I have more than one entry for the same ID# and I don’t want to count duplicate ID#s.
    Thanks
    ID# Dates
    UTIC05019_000 7/14/2015
    UTIC05019_000 7/14/2015
    UTIC05019_000 7/14/2015
    UTIC05019_000 7/14/2015
    UTIC05021_000 6/24/2015
    UTIC05021_000 6/24/2015
    UTIC05021_000 6/24/2015
    UTIC05022_000 6/27/2015
    UTIC05022_000 6/27/2015
    UTIC05023_000 6/28/2015
    UTIC05023_000 6/28/2015
    UTIC05027_000 6/28/2015
    UTIC05027_000 6/28/2015
    UTIC05030_000 6/26/2015
    UTIC05030_000 6/29/2015
    UTIC05030_000 6/29/2015
    UTIC05030_000 6/29/2015
    UTIC05030_000 7/1/2015
    UTIC05032_000 7/8/2015
    UTIC05032_000 7/8/2015
    UTIC05032_000 7/8/2015

  33. Hi,

    I have a table to do with letting of properties, table has following info 'property' 'type of property''applicant names' 'type of applicant, UOCC, HGR, FTA, TRA, MTA' and also the date that a property has been let.

    I would need to count per calendar month, how many properties were let per applicant type?

    Your help is much appreciated.

    Thank you

  34. Hello Svetlana,

    the following formula is giving me some sintax error in the last field. I am trying to create a criteria ">=" that refers to another spreadsheet.

    =COUNTIFS('Sheet1'!D1:D10,'Sheet2'!C5,'Sheet1'!I1:I10,'Sheet2'!">="&'Sheet2'!G3)

    What would be the right expression? Thanks a lot,

    Jose

    1. Hi Jose,

      The criteria can be expressed as follows:
      =COUNTIFS(Sheet1!D1:D10,Sheet2!C5,Sheet1!I1:I10,">="&Sheet2!G3)

      Is this what you are looking for?

  35. Hello Svetlana,

    I'm creating an wedding invite spreadsheet. I have four columns: NAME, GUESTS, RESPONSE, AMT ATTENDING. I would like to to create a conditional cell (AMT ATTENDING) on each row that will determine how many are attending. So, if the RESPONSE cell has 'N', the AMT ATTENDING cell on that should equal 0. If the RESPONSE cell equals 'Y', the ATTENDING cell should equal the GUESTS cell on the same row.

    Is this possible? Thank you so much!

    1. Hi!

      Of course, you can do this by copying the following IF formula in AMT ATTENDING column beginning in row 2:

      =IF(C2="N", 0, IF(C2="Y", B2, ""))

      Where C is RESPONSE and B is GUESTS.

      1. Works perfectly! Thank you!!

  36. Hello,
    I want to use the countifs formula when the value in cell E2 is present in the list PROSPECT AND when the value in cell L2 is in the list REGULAR.
    I use the formule :
    =COUNTIFS(PROSPECT;E2;REGULAR;L2)
    However it returns #VALUE!
    It works perfectly when I use a single countif formula : =COUNTIF(PROSPECT;E2)
    Can you help please?

    1. Hi Bea,

      The first thing that comes to mind is checking if PROSPECT and REGULAR lists are of the same size, since the syntax of COUNTIFS requires that all the ranges have the same number of rows and columns. Is this the case?

      1. Hi Svetlana,
        they are 2 columns in a separate sheet. 1 containing 10 values, the other only 3.
        Is that what you mean?

        1. Hi Bea,

          Exactly. For the COUNTIFS formula to work, both lists must have the same number of rows.

  37. Hi,
    I have a countif function that is working:

    =COUNTIF('Sheet1'!C:C,"<=10/07/2015")

    but I want to swap the date out for a cell reference e.g $AI$1 (will still contain the same date format). I cannot seem to get this to work.

    Please help!

    1. Hi Rachel,

      The following formula seems to be the one you are looking for:
      =COUNTIF('Sheet1'!C:C,"<="&$AI$1)

  38. Dear Svetlana,

    I want to count the numbers when Cell value of Column A is less than Cell value of Column B of same row. Also want to apply the same logic for continuous 10-12 rows.

    Kindly suggest

    1. Shubham,

      Because your task requires comparing 2 ranges, you need an array formula like this:
      =SUM((A1:A12<B1:B12) * 1)

      Due to it being an array formula, you must press Ctrl+Shift+Enter to enter the formula correctly.

  39. hello, I really need help with this.
    I have two sheets- the first one has an option to put in a date range as seen below:

    Start Date End Date
    14/07/2015 22/07/2015

    in the second sheet i have a yearly schedule for all my staff, but the way i have it laid out is the number of staff that will be in the office in the first column and the date will be in the second column, like below:

    staffed Date
    20 13/07/2015
    21 14/07/2015
    22 15/07/2015
    20 16/07/2015
    19 17/07/2015

    What i need the formula to do is check the date range in the first sheet against the numbers and dates in the second one and return a value.

    Example- i put a start and end date of my holidays into it, it checks the sheet and if i have less than 20 staffed on any of the dates specified it will say rejected. put if there is 20 or more staffed each day it will say approved.

  40. Hi,

    I am working on a spreadsheet that has some strings in columns A2:K2.
    In a separate sheet I have in rows A2:A15 some strings (PP1, PP2, PP3...PP15)
    In cell L2 I want to be able to put a formula to count how many time any of the strings in A2:A15 appear in A2:K2.

    Thank you any help in greatly appreciated.

    Matt

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

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

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

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

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

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

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

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

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

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

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