The tutorial explains how to use COUNTIFS and COUNTIF formulas with multiple criteria in Excel based on AND as well as OR logic. You will find a number of examples for different data types - numbers, dates, text, wildcard characters, non-blank cells and more.
Of all Excel functions, COUNTIFS and COUNTIF are probably most often mixed up because they look very much alike and both are purposed for counting cells based on the specified criteria.
The difference is that COUNTIF is designed for counting cells with a single condition in one range, whereas COUNTIFS can evaluate different criteria in the same or in different ranges. The aim of this tutorial is to demonstrate different approaches and help you choose the most efficient formula for each particular task.
Excel COUNTIFS function - syntax and usage
The Excel COUNTIFS function counts cells across multiple ranges based on one or several conditions. The function is available in Excel 365, 2021, 2019, 2016, 2013, Excel 2010, and Excel 2007, so you can use the below examples in any Excel version.
COUNTIFS syntax
The syntax of the COUNTIFS function is as follows:
- criteria_range1 (required) - defines the first range to which the first condition (criteria1) shall be applied.
- criteria1 (required) - sets the condition in the form of a number, cell reference, text string, expression or another Excel function. The criteria defines which cells shall be counted and can be expressed as 10, "<=32", A6, "sweets".
- [criteria_range2, criteria2]… (optional) - these are additional ranges and their associated criteria. You can specify up to 127 range/criteria pairs in your formulas.
In fact, you don't have to remember the syntax of the COUNTIF function by heart. Microsoft Excel will display the function's arguments as soon as you start typing; the argument you are entering at the moment is highlighted in bold.
Excel COUNTIFS - things to remember!
- You can use the COUNTIFS function in Excel to count cells in a single range with a single condition as well as in multiple ranges with multiple conditions. If the latter, only those cells that meet all of the specified conditions are counted.
- Each additional range must have the same number of rows and columns as the first range (criteria_range1 argument).
- Both contiguous and non-contiguous ranges are allowed.
- If the criteria is a reference to an empty cell, the COUNTIFS function treats it as a zero value (0).
- You can use the wildcard characters in criteria - asterisk (*) and question mark (?). See this example for full details.
How to use COUNTIFS and COUNTIF with multiple criteria in Excel
Below you will find a number of formula examples that demonstrate how to use the COUNTIFS and COUNTIF functions in Excel to evaluate multiple conditions.
How to count cells with multiple criteria (AND logic)
This scenario is the easiest one, since the COUNTIFS function in Excel is designed to count only those cells for which all of the specified conditions are TRUE. We call it the AND logic, because Excel's AND function works this way.
Formula 1. COUNTIFS formula with multiple criteria
Suppose you have a product list like shown in the screenshot below. You want to get a count of items that are in stock (value in column B is greater than 0) but have not been sold yet (value is column C is equal to 0).
The task can be accomplished by using this formula:
=COUNTIFS(B2:B7,">0", C2:C7,"=0")
And the count is 2 ("Cherries" and "Lemons"):
Formula 2. COUNTIFS formula with two criteria
When you want to count items with identical criteria, you still need to supply each criteria_range / criteria pair individually.
For example, here's the right formula to count items that have 0 both in column B and column C:
=COUNTIFS($B$2:$B$7,"=0", $C$2:$C$7,"=0")
This COUNTIFS formula returns 1 because only "Grapes" have "0" value in both columns.
Using a simpler formula with a single criteria_range like COUNTIFS(B2:C7,"=0") would yield a different result - the total count of cells in the range B2:C7 containing a zero (which is 4 in this example).
How to count cells with multiple criteria (OR logic)
As you have seen in the above examples, counting cells that meet all of the specified criteria is easy because the COUNTIFS function is designed to work this way.
But what if you want to count cells for which at least one of the specified conditions is TRUE, i.e. based on the OR logic? Overall, there are two ways to do this - by adding up several COUNTIF formulas or using a SUM COUNTIFS formula with an array constant.
Formula 1. Add up two or more COUNTIF or COUNITFS formulas
In the table below, supposing you want to count orders with the "Cancelled" and "Pending" status. To have it doen, you can simply write 2 regular Countif formulas and add up the results:
=COUNTIF($C$2:$C$11,"Cancelled") + COUNTIF($C$2:$C$11,"Pending")
In case each of the functions is supposed to evaluate more than one condition, use COUNTIFS instead of COUNTIF. For example, to get the count of "Cancelled" and "Pending" orders for "Apples" use this formula:
=COUNTIFS($A$2:$A$11, "Apples", $C$2:$C$11,"Cancelled") + COUNTIFS($A$2:$A$11, "Apples", $C$2:$C$11,"Pending")
Formula 2. SUM COUNTIFS with an array constant
In situations when you have to evaluate a lot of criteria, the above approach is not the best way to go because your formula would grow too big in size. To perform the same calculations in a more compact formula, list all of your criteria in an array constant, and supply that array to the criteria argument of the COUNTIFS function. To get the total count, embed COUNTIFS inside the SUM function, like this:
In our sample table, to count orders with the status "Cancelled" or "Pending" or "In transit", the formula would go as follows:
=SUM(COUNTIFS($C$2:$C$11, {"cancelled", "pending", "in transit"}))
In a similar manner, you can count cells based on two or more criteria_range / criteria pairs. For instance, to get the number of "Apples" orders that are "Cancelled" or "Pending" or "In transit", use this formula:
=SUM(COUNTIFS($A$2:$A$11,"apples",$C$2:$C$11,{"cancelled","pending","in transit"}))
You can find a few more ways to count cells with OR logic in this tutorial: Excel COUNTIF and COUNTIFS with OR conditions.
How to count numbers between 2 specified numbers
By and large, COUNTIFS formulas for numbers fall into 2 categories - based on several conditions (explained in the above examples) and between the two values you specify. The latter can be accomplished in two ways - by using the COUNTIFS function or by subtracting one COUNTIF from another.
Formula 1. COUNTIFS to count cells between two numbers
To find out how many numbers between 5 and 10 (not including 5 and 10) are contained in cells C2 through C10, use this formula:
=COUNTIFS(C2:C10,">5", C2:C10,"<10")
To include 5 and 10 in the count, use the "greater than or equal to" and "less than or equal to" operators:
=COUNTIFS(B2:B10,">=5", B2:B10,"<=10")
Formula 2. COUNTIF formulas to count numbers between X and Y
The same result can be achieved by subtracting one Countif formula from another. The first one counts how many numbers are greater than the lower bound value (5 in this example). The second formula returns the count of numbers that are greater than the upper bound value (10 in this case). The difference between the first and second number is the result you are looking for.
- =COUNTIF(C2:C10,">5")-COUNTIF(C2:C10,">=10") - counts how many numbers greater than 5 and less than 10 are in the range C2:C10. This formula will return the same count as shown in the screenshot above.
- =COUNTIF(C2:C10, ">=5")-COUNTIF(C2:C10, ">10") - the formula counts how many numbers between 5 and 10 are in the range C2:C10, including 5 and 10.
How to use cell references in COUNTIFS formulas
When using logical operators such as ">", "<", "<=" or ">=" together with cell references in your Excel COUNTIFS formulas, remember to enclose the operator in "double quotes" and
add an ampersand (&) before a cell reference to construct a text string.
In a sample dataset below, let's count "Apples" orders with amount greater than $200. With criteria_range1 in cells A2:A11 and criteria_range2 in B2:B11, you can use this formula:
=COUNTIFS($A$2:$A$11, "Apples", $B$2:$B$11, ">200")
Or, you can input your criteria values in certain cells, say F1 and F2, and reference those cells in your formula:
=COUNTIFS($A$2:$A$11, $F$1, $B$2:$B$11, ">"&$F$2)
Please notice the use of absolute cell references both in the criteria and criteria_range arguments, which prevents the formula from being broken when copied to other cells.
For more information about the use of an ampersand in COUNTIF and COUNTIFS formulas, please see Excel COUNTIF - frequently asked questions.
How to use COUNTIFS with wildcard characters
In Excel COUNTIFS formulas, you can use the following wildcard characters:
- Question mark (?) - matches any single character, use it to count cells starting and/or ending with certain characters.
- Asterisk (*) - matches any sequence of characters, you use it to count cells containing a specified word or a character(s) as part of the cell's contents.
Tip. If you want to count cells with an actual question mark or asterisk, type a tilde (~) before an asterisk or question mark.
Now let's see how you can use a wildcard char in real-life COUNTIFS formulas in Excel. Suppose, you have a list of projects in column A. You wish to know how many projects are already assigned to someone, i.e. have any name in column B. And because we are learning how to use the COUNTIFS function with multiple criteria, let's add a second condition - the End Date in column D should also be set.
Here is the formula that works a treat:
=COUNTIFS(B2:B10,"*",D2:D10,"<>"&""))
Please note, you cannot use a wildcard character in the 2nd criteria because you have dates rather that text values in column D. That is why, you use the criteria that finds non-blank cells: "<>"&""
COUNTIFS and COUNTIF with multiple criteria for dates
The COUNTIFS and COUNTIF formulas you use for dates are very much similar to the above formulas for numbers.
Example 1. Count dates in a specific date range
To count the dates that fall in a certain date range, you can also use either a COUNTIFS formula with two criteria or a combination of two COUNTIF functions.
For example, the following formulas count the number of dates in cells C2 through C10 that fall between 1-Jun-2014 and 7-Jun-2014, inclusive:
=COUNTIFS(C2:C9, ">=6/1/2014", C2:C9, "<=6/7/2014")
=COUNTIF(C2:C9, ">=6/1/2014") - COUNTIF(C2:C9, ">6/7/2014")
Example 2. Count dates with multiple conditions
In the same manner, you can use a COUNTIFS formula to count the number of dates in different columns that meet 2 or more conditions. For instance, the below formula will find out how many products were purchased after the 20th of May and delivered after the 1st of June:
=COUNTIFS(C2:C9, ">5/1/2014", D2:D9, ">6/7/2014")
Example 3. Count dates with multiple conditions based on the current date
You can use Excel's TODAY() function in combination with COUNTIF to count dates based on the current date.
For example, the following COUNTIF formula with two ranges and two criteria will tell you how many products have already been purchased but not delivered yet.
=COUNTIFS(C2:C9, "<"&TODAY(), D2:D9, ">"&TODAY())
This formula allows for many possible variations. For instance, you can tweak it to count how many products were purchased more than a week ago and are not delivered yet:
=COUNTIFS(C2:C9, "<="&TODAY()-7, D2:D9, ">"&TODAY())
This is how you count cells with multiple criteria in Excel. I hope you will find these examples helpful. Anyway, I thank you for reading and hope to see you on our blog next week!
2039 comments
Hi there, I am trying to program a workbook to pull data from different sheets and am hitting a roadblock in trying to program my COUNTIFS formula with multiple criteria.
I am pulling survey data and am looking at the number of compliments per city. In this instance, I have it programmed to pull the comment number that are compliments and from the city, but where I am running into trouble is that the city field comes back to me and can reflect the city of North Fort Myers as "NORTH FORT M" and "N FORT MYERS".
I am trying to figure out how I can program it so both of these are picked up for the same total number. I currently have my formula as =COUNTIFS(Test!O:O,List!W2,Test!D:D,List!C2). But for the data in column D, I want it to be pulled if it reflects the info from cells C2 and D2.
Hoping this is clear and you can help! Thanks.
Hi! Unfortunately, the COUNTIFS function cannot calculate approximate matches. To use the formulas, correct the typos. You can use the Find Fuzzy Duplicates tool to do this. It is available as a part of our Ultimate Suite for Excel that you can install in a trial mode and check how it works for free.
Hi Alexander,
I'm trying to use Countifs with Text.
I have a column with Girls attending classes. In that column I write yes or No.
I then would like to calculate or create a formula in a separate column, that if that specific cell says "Yes" it would allow the formula to occur if it says "No" it would just appear as £0.
Hoping you can help me.
Thanks
Is this also possible to occur with a Dropdown with either yes or no? And How would I allow the formula to occur or have it cancel it out if it say no.
Thanks
Hello! I don't really understand what result you want to get. If you want to count the quantity "Yes", use the COUNTIF function: COUNTIF(B2:B10,"Yes")
If you want to calculate a formula by condition, use the IF function.
Hi Alexander,
What would be the formula for the following example:
Column A has three entries "house", "bungalow" or "flat". Column B has the 'area' of the building. I want to calculate the total area when Column A has either "house" or "bungalow" entered.
I hope this makes sense!
Thanks :)
Hi! The following tutorial should help: Excel SUMIFS and SUMIF with multiple criteria – formula examples.
For example,
=SUMIFS(B1:B10,A1:A10,"house") + SUMIFS(B1:B10,A1:A10,"bungalow")
Hi, I am trying to total how many times a participant has attended a class over a 6 week period. I have Column A containing the names of participants, column B containing the date attended. These participants names listed in column A are repeated in alot of cases as they might attend multiple times over this period. I am wanting to lookup column A, find the exact same names/search criteria and return a total "number" for the sum of how many times their name appears over this period. This would then tell me that "Joe Blow" attended this class 20 times over a 6 week period. Thank you. Ruth :-)
Hi! I hope you have studied the recommendations in the tutorial above. It contains answers to your question. Here is an example formula for your case:
=COUNTIFS(A1:A100,"Joe Blow", B1:B100,"<"&TODAY(), B1:B100,">"&(TODAY()-42))
Hi,
I have 2 columns. Column A shows the time and Column B indicates if a button is pushed with 1='button pushed' and 0='button not pushed'. i need to measure the time between every button push (or the number of cells between each '1' because each cell is equal to 1 minute) but the data spans over 2 weeks (=20 000++ cells). is there a way to make a list of the duration for every "downtime" (time between every button push) without doing them one by one?
for example, collumn B would look something like this:
0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,....
so the first downtime is 22 minutes, second downtime is 6 minutes, third downtime is 18 minutes and so on.
thanks in advance!
Hi! If I understand your task correctly, the following formula should work for you:
=SEARCH("#",SUBSTITUTE(CONCAT($B$1:$B$3000),"1","#",ROW(A2))) - SEARCH("#",SUBSTITUTE(CONCAT($B$1:$B$3000),"1","#",ROW(A1)))-1
Copy this formula down along the column. I hope this will help.
Thank you so much! it works wonderfully!
I changed the '3000' in '$B$3000' to the number of the final cell.
why do we need to use ROW(A1)? I substituted it with 1,2,3,.... and it work just fine, but your method also work. what is the difference?
If you copy the formula down along the column, the value of ROW(A1) will automatically change and return 1,2,3...
Ok everything is clear now! thanks again!
I need help in my file as per below sample.
I have multiple items, some are with same "PCA P/N" and some are not same and it has different date reject each PCA P/N recorded.
Then, what I need is to count the specific PCA P/N which still "OPEN" status and with less than 30days from now.
Another column and formula is for less than 60 days, and next is less than 90days from now.
For example the Date Reject is at column A:A, PCA P/N is at column B:B and the status is at column C:C.
Date Reject PCA P/N STATUS
5-Aug-22 AEM5300-66402 open
Hope you guys understand my statement.
Hi! If I understand your task correctly, try the following formula:
=SUM(((TODAY()-A1:A20)<30)*(B1:B20="AEM5300-66402")*(C1:C20="open"))
or
=SUMPRODUCT(--((TODAY()-A1:A20)<30),--(B1:B20="AEM5300-66402"),--(C1:C20="open"))
For more information, please visit: Excel SUMPRODUCT function with multiple criteria - formula examples.
Thanks for your response. But after I've tried, this is the results.
for this one -> =SUM(((TODAY()-A1:A20)<30)*(B1:B20="AEM5300-66402")*(C1:C20="open")) results shows "0".
and for the 2nd formula shows #VALUE!.
I'll check on your link provided for more other info.
Thanks again.
I'm checking the error and evaluate the formula shows the date is "45072-A1:A20".What do i need to change or format?
I wrote this formula based on the description you provided in your original comment. I can't see your data and can't know what dates you are comparing. Also check the dates in column A. If it's text and not dates, the formula doesn't work. Please note that if you’d provided me with the precise and detailed description of your task from the very beginning, I’d have created a different formula that would have worked for your case.
Hi Sir,
Appreciated your response and thank you.
Actually the output should be like this.
Model <30 days <60 days <90 days 120 days
M5300-66401 8 3 1 0 3
Everyday it will count those within 30 days from today, those within 60days from today and so on.
Those status still "open", and yes the column A is formatted as date.
By right your formula will work but i don't get it also why having error.
Hi! Your answer does not contain any new data that would help give you advice. Check column A. I think it contains text that is formatted as a date. Pay attention to the following article: How to convert text to date in Excel.
Hi, Please help with the below formula.
The top performer's indication with a yes or no is in column "L". Country is in column X. Now I would like to understand the % of top performers in the United Kingdom and Ireland countries. Used the below formulae but couldn't get the correct %. Please help.
=COUNTIFS('Successors List'!L:L,"Yes",'Successors List'!X:X,"United Kingdom","Ireland")/COUNTIF('Successors List'!L:L,"Yes")
* To clarify, the "Successors list" is the top performers list in the Excel file.
Hi! Pay attention to the following paragraph of the article above: How to count cells with multiple criteria (OR logic).
It covers your case completely.
COUNTIFS('Successors List'!L:L,"Yes",'Successors List'!X:X,"United Kingdom") + COUNTIFS('Successors List'!L:L,"Yes",'Successors List'!X:X,"Ireland")
Hi, Many many thanks for responding. I've used the formula already. However, it shows 3000% which is weird. Do you know why is it not giving the right %?
I can't check your formula because I don't have your data.
Hi!
Would love some formula help here, if possible.
Sheet 1: Customer email (column A), Survey completion date (column B)
Sheet 2: Customer email (column A), Order date (column B), Unique order # (column C)
On Sheet 1 in column C, would like a formula to count quantity of unique orders on Sheet 2 by customer email BEFORE OR ON the survey completion date
Is this something you could help me with?
Hello!
If I understand your task correctly, the following formula should work for you:
=SUM((COUNTIFS('1'!A1:A10,'2'!A1:A10,'1'!B1:B10,">="&'2'!B1:B10)))
Hi Alexander,
I follow your topics and website. You are genius of solving the problems. And you help me many times here.
My question is:
I have one cell A1. Every week in this cell is entering one of this letters ("A", "B", "C","D") from another sheet. . I want to count this letter and multiply by different number.
For Example: countif(A1,"A")*13.75 ........... countif(A1,"D")*2.75 ............ countif(A1,"C")*5.5 ............... countif(A1,"B")*8.25
I want to put this in one formula.
Thank you
Hi! You can get a number depending on the value of the cell using the IFS function.
IFS(A1="A",13.75,A1="B",2.75,A1="C",5.5,A1="D",8.25)
But I'm not understood what result you want to get and why you should use COUNTIF in the one cell.
I thought that I have to use countifs, because i have multiple criterias. Also think about IF with OR. But couldn't put together.
Thank you for quick response.
Result is based on £. For example: if in that cell A1 is D, then I want to be multiplied by 2.75£. People are receiving bonuses for their hard work.
I make setup with your formula IFS and this solve my problem.
Thank you very much.
how can i count total number of unstanding payment for one registration number ( different pay rate) from different worksheet( one worksheet for one month) for the whole year.
Hi! Create a COUNTIFS formula for each sheet separately, and then sum them up.
Maybe this article will be helpful: Excel reference to another sheet or workbook (external reference)
Hi,
Could you please help to solve below problem?
I just need to get the result with count of text from two columns in a particular range whether the values are same for both cells or different in both cells, the values shall be counted as one only.
Example:
A B
Apple Orange
Orange Mango
Apple Orange
Apple 2
Orange 3
Mango 1
Sorry, a change in example:
A B
Apple Apple
Orange Mango
Apple Orange
Apple 2
Orange 2
Mango 1
Hi! To count the number of values by condition, use COUNTIF function and this guide: COUNTIF function in Excel - count if not blank, greater than, duplicate or unique.
For example:
=COUNTIF(A1:B6,"apple")
=SUM(COUNTIFS($A$2:$A$11,"apples",$C$2:$C$11,{"cancelled","pending","in transit"}))
how we write like this
=SUM(COUNTIFS($A$2:$A$11,"apples",$C$2:$C$11,{"="&H1(Like),"="&H2(Like), "="&H3(Like),"="&H4(Like)}))
Hi! Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
Hi
I'm looking at calculating the count of employees who belong to the United Kingdom and Ireland. But I need to calculate just within 4 cells and not more.
The country is in the AF column, and I need to look at the formula calculating no. of employees who are in the UK and Ireland in 2 different time frames.
Used the below formula but is not working. AF52:AF53 is one time frame and AF57:AF58 is another timeframe.
=COUNTIFS(AF52:AF53,"United Kingdom",AF57:AF58,"United Kingdom") + COUNTIFS(AF52:AF53,"Ireland",AF57:AF58,"Ireland")
Please help!!!
Hi! I can't check your formula because I don't have your data. Note, however, that the COUNTIFS function only counts when, for example, AF52=AF57="United Kingdom"
This may help.
=COUNTIFS(AF52:AF53,{"United Kingdom","Ireland"})+COUNTIFS(AF57:AF58,{"United Kingdom","Ireland"})
Hi,
How do copy the formula to another cell with skipping AZ-BA (2 Columns) of data.
=COUNTIFS(AV$6:AV$75,"12x12",AW$6:AW$75,"Prep")+COUNTIFS(AV$6:AV$75,"12x12",AX$6:AX$75,"Prep-c")+COUNTIFS(AV$6:AV$75,"12x12",AY$6:AY$75,"Prep")
into
=COUNTIFS(BB$6:BB$75,"12x12",BC$6:BC$75,"prep")+COUNTIFS(BB$6:BB$75,"12x12",BD$6:BD$75,"Prep")+COUNTIFS(BB$6:BB$75,"12x12",BE$6:BE$75,"prep")
Hi!
I recommend reading this guide: How to copy formula in Excel with or without changing references.
Hi,
I have this table with list of names and 3 columns for the status. The reference is from another sheet. i used countifs with 2 conditions and working except for 2 names, that returns the value of 0. I checked the reference and they should value greater than 0. I tried it also in google sheet and got the same result. Also, tried changing the format but no changes. Hope you can help. Thank you.
The formula is like this
=COUNTIFS(Sheet2!A:A,A2,Sheet2!B:B,B1)
Hope you can help. Thank you.
Can anyone
Hi! I can't check your formula because I don't have your data. It is possible that your values have extra spaces, unprintable characters, or decimals that are hidden by the number formatting.
Hi! I would like to ask about, what formula is the best for this situation:-
COLOUMN A : Name of officer
COLOUMN B : Name of officer
COLOUMN C : Numbers of day taken to complete the task
Reason why there are two column is the task need to 2 officers to be completed. So the question is, how do I want to count if the officer (e.g Lisa) has completed her task less than 7 days.
Thank you.
Hi! You can use the COUNTIFS function to calculate an sum for several conditions. Use this guide: How to use Excel COUNTIFS and COUNTIF with multiple criteria.
It is not possible to give more detailed advice since you have not provided any data.
I need some help! I am an OB provider and in the last 6 years, my male-to-female fetus ratio is 2:1 (which is wild). I am trying to see if the sex discrepancy is the strongest based on specific indications (such as mothers over 35 or patients I saw due to sonogram anomalies). I have my indications (the reason they saw me) in one column and male or female in another column. I use this [COUNTIF(F:F, "(u/s)*")] to indicate patients that were seen due to sonogram anomalies and [COUNTIF(I:I,"*male*")] to indicate all male fetuses.
Can I combine the two and see whether the indication changes the sex ratio?
Hello!
If I understand your question correctly, try using the COUNTIFS function to count values for the two conditions:
COUNTIFS(F:F, "(u/s)*", I:I,"*male*")
Look for the example formulas here: Excel COUNTIFS and COUNTIF with multiple AND / OR criteria.
Hi Alexander!
Thanks for your blog, it's very useful. I had a question, I hope you can help me. I would like to count how many cells in a column contain simultaneously certain words (not just one word, as CTRL+F would be enough). Let me explain better.
I'm doing a list of magazine articles that talk about several topics, I'm classifying them. For example, let's say I have 50 articles, one listed under the other (in 50 rows), and categorized through 4 criteria (columns): theme of the Article (column A), Author (column B), Title (column C), Editor (column D).
The important one is Column A, where I list the topics each of the articles talks about. So in each cell of Column A, for each article, I put certain keywords separated by commas. Example:
column A (Topics present in the article) column B (author) column C (title) column D (editor)
Row/article 1: food, travel, social media, money XXXXX XXXXX XXXXX
Row/article 2: food, money, tourism XXXXX XXXXXX XXXXX
Row/article 3: travel, food, sustainability
Row/article 4: social media, money, travel
Row/article 5: sustainability, food, social media
QUESTION: How many cells of column A contain both "food" and "travel"? Or both "travel" AND "money" AND "food"?
I would like to know many articles talk about several topics at the same time, so how many times certain keywords are mentioned simultaneously within the same cell. For example, how many articles talk about both food and travel (how many cells of column A contain both "food" and "travel")? How many articles talk about both money and social media (how many cells of column A contain both "money" and "social media")? And even three topics simultaneously.
Thanks in advance for your help!
Take care,
Hi!
Find a partial match of the text strings using the SEARCH function.
=SUM(--ISNUMBER(SEARCH("food",A1:A20))*(--ISNUMBER(SEARCH("travel",A1:A20))))
For more information, please read: How to find substring in Excel
Thanks for your answer!
Maybe I didn't understand something because when I try to apply the formula to the desired column it doesn't show the correct results. For example I know for sure at least 5 cells contain simultaneously two certain words, and still the formula tells me only one cell does, or none.
I mean, does it count how many cells IN TOTAL in a certain column contain at least the words used in the formula, or the formula just works for each cell individually? Sorry forr my question, I'm not that familiar with Excel.
Thanks again,
Hi!
The formula counts how many cells in the range contain 2 words at the same time. I can't see your data, but the formula works for me.
Hello there!
Yes, indeed the formula works, thanks! The only issue is the range. Instead of giving me the results for the whole range (like 10 articles in total mentioning X and Y), it only works for individual cells: I have to drag the formula down, in paralel to the column with the keywords I want to count, and it gives a list of results per cell (like 0, 0, "1", 0, 0, "1", 0, "1", etc.), not the total of the range ("3"). I don't understand why.
So I then have to sum the whole column of results to have the total number of articles mentioning the chosen words. It's like the "extracting part" works, indentifying the words, but the "sum part" doesn't for the whole range, only for individual cells.
I could send you a part of the file as an example or screenshots, no problem.
Thanks again!
Dear Alexander,
Sorry to bother again, I think found a SOLUTION, I wanted to let you know in case future users find it useful.
I simply modified your formula a little bit, changing the =sum with =sumproduct. This way it shows the final results for the whole range of interest in a single cell:
=SUMPRODUCT(--ISNUMBER(SEARCH("KEYWORD1",A:A))*(--ISNUMBER(SEARCH("KEYWORD2",A:A))))
Do you think there is a way to see highlighted the results? I mean, not just knowing the number of cells that contain specific keywords, but also knowing which ones in order to find the articles of interest.
Thanks again for your time, it's incredible how helpful you are and I definetively save this page.
Have a nice day!
Hi! To get cell values that contain specific keywords, you can use the FILTER function. The following tutorial should help: Excel FILTER function - dynamic filtering with formulas.
Hi,
I wonder if you could help me. I have table need to find the correct formula to use,
i want to count the duplicate with multiple creteria.
example :
time date customer Flavour number invoice
2:43 am 07/04/2023 linda jitsu 123
2:44 am 07/04/2023 linda Belt 456
2:45 am 07/04/2023 Henry Belt 789
2:45 am 07/04/2023 Henry Belt 897
2:45 am 07/04/2023 Henry jitsu 456
2:46 am 07/04/2023 Henry Belt 789
how we use countif for flavour Jitsu will show duplicate if more than 1 time entry and for flovour Belt will show duplicate if more than 3 times entry?
Hoping for your help in this matter .
Thank you very much
Best Regards
Hi!
If you want to show products that meet more than 3 times, try the methods suggested in this guide: How to find duplicates in Excel.
For example:
=IF(COUNTIF($D$2:$D$8, $D2)>3, "Duplicate", "")
Hi, I have 2 different set of list boxes 1) Overall, Ops, Apps 2) Overall, CR, BF, AT
KPI Oct-22
TTM 0
As mentioned in the above, i would like to calculate TTM count using above list box combinations. Could you please help
Have you experimented with the suggested techniques in the blog post? If they weren't effective, please provide me with more details about your task, and I'll do my best to recommend a solution.