Solved

# Using Countifs on the same Column Multiple Times

Posted on 2013-01-16
312 Views
Is it possible to use Countifs in this way:

I would like to count X if A is true and B is true or C is true or D is true or E is true .
B, C, D, and/or E are all in Column O. A is in column P

So essentially I'm looking for a way to make the formula work with:

Countifs(P:P, "variable A", AND O:O, "variable B", OR O:O "variable C", OR O:O, "variable D") etc....

If not, what can I use to accomplish?
0
Question by:-Polak
• 2

LVL 7

Expert Comment

Hi,

I would use SUMPRODUCT with boolean-arrays, where multiplication corresponds AND and addition corresponds OR, so something like:
=SUMPRODUCT((P1:P10="A")*((O1:O10="B")+(O1:O10="C")+(O1:O10="D")))

in this part:
((O1:O10="B")+(O1:O10="C")+(O1:O10="D"))
you use the same column, so it is not possible that two or more part is true at the same time. If it is not the case, you need to use an additional checking:
=SUMPRODUCT((P1:P10="A")*(((O1:O10="B")+(O1:O10="C")+(N1:N10="D"))>0))

Anyway, would be great to see the original problem to write the correct boolean-tests.

Cheers,
Kris
0

LVL 50

Accepted Solution

barry houdini earned 500 total points
Try this setup

=SUM(COUNTIFS(P:P,"A",O:O,{"B","C","D","E"}))

regards, barry
0

LVL 7

Expert Comment

wow, that is great barry! I did not know it could work this way with array.
0

LVL 1

Author Closing Comment

Beautiful, I'm glad we could all learn something here today.
0

## Featured Post

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.