A few days back I wrote about how we can use SUMIF OR. And today, I want to show that by using the same logic we can create a COUNT OR formula.
Even we can create dynamic criteria in this formula. But first of all, let me ask you something.
Have you ever faced a situation where you need to count more than one value from a single column or a range of cells?
If yes, then using this OR logic in COUNTIF/COUNTIFS can be a game-changer for you.
The thing is, normally, when we COUNTIF we can just count cells by specifying a single condition and with COUNIFS we can specify more than one condition but it uses AND logic to count values.
That means we can’t use these functions to count more than a value from a single column or a range.
But today in this post, I’d like to share with you a simple but powerful way to apply OR condition in COUNIF.
Make sure to download this data file from here and now, let’s get started…
How to use COUNTIF/COUNTIFS OR
Have a look at the below data where you have a list of people and their favorite social media platforms.
Now, from this list of 50 people, you need to count how many people like “Facebook” and “Twitter”. If you want to use COUNIF then insert the below formula in a cell and hit enter.
And, if you want to use COUNIFS then insert the below formula in a cell and hit enter.
With both of the above formulas, you will get 25 in the result which is the count of both Facebook (17) + Twitter (8) combined.
How it Works
As I mentioned earlier, COUNTIFS uses AND logic and on the other hand, in COUNIF you can only specify one value to count.
To understand the application of OR with these functions you need to split this formula into three parts.
- First of all, we have used two different criteria in this formula by using the array concept.
- And after that, we used COUNTIFS to look for these two values.
- In the end, we have enclosed the entire formula in the SUM function to get the joint count of both of the values.
Here I have explained this concept in COUNTIF but the COUNTIFS formula will work in the same way.
Dynamic OR Condition
When I explained about using OR in SUMIF/SUMIFS, Shay asked me how can he use dynamic values instead of using hardcore values in this formula.
And for this, you need to do just two little amendments to your formula.
- The first is, instead of using curly brackets you need to use a named range (the best way is to use a table) of your values.
- And after that, you need to enter this formula by using Ctrl + Shift + Enter as a proper array formula.
So, now your formula will be:
Get the Excel File
Using OR logic in COUNIF/COUNIFS can increase its power and save you from writing long formulas.
And, using dynamic criteria is super awesome. You can change values anytime you want, without changing the formula.
I hope you found these formula tips useful and that they will help you to become more efficient in your work.
So, what do you think about this one?
Have you tried this anytime before this?
Share your views with me in the comment section, I’d love to hear from you. And, please don’t forget to share this tip with your friends.