Solved

COUNTIFS formula not counting correctly

Posted on 2013-06-05
6
445 Views
Last Modified: 2013-06-06
Hello, I'm using:

=SUM(COUNTIFS($P:$P, "Program Planning & Policy",$O:$O, {"AZ","CA","DC","IN","LA","ME","MI","NC","NY","PR","TX","VT","WA"},$S:$S, {"Reg.","IS"}))

To try an count some data, however it seem if I try to add the add the additional criteria to the last range of "IS" the formula no longer works.... If I'm just counting for "Reg." or "IS" individually it counts correctly....

Why can't I count the last range for 2 criteria... is there an alternate work around apart from doing two COUNTIFS ala:

=SUM(COUNTIFS($P:$P, "Program Planning & Policy",$S:$S, "Reg.",$O:$O, {"AZ","CA","DC","IN","LA","ME","MI","NC","NY","PR","TX","VT","WA"}),COUNTIFS($P:$P, "Program Planning & Policy",$S:$S, "IS",$O:$O, {"AZ","CA","DC","IN","LA","ME","MI","NC","NY","PR","TX","VT","WA"}))
Dummy.xlsx
0
Comment
Question by:-Polak
  • 3
  • 2
6 Comments
 
LVL 23

Expert Comment

by:NBVC
ID: 39223042
It's because the criteria arrays aren't the same size....

Try:

=SUMPRODUCT((P1:P10="Program Planning & Policy")*(ISNUMBER(MATCH(O1:O10,{"AZ","CA","DC","IN","LA","ME","MI","NC","NY","PR","TX","VT","WA"},0)))*(ISNUMBER(MATCH(S1:S10,{"Reg.","IS"},0))))

adjust ranges to suit... but do not use unnecessarily large ranges.
0
 
LVL 50

Accepted Solution

by:
barry houdini earned 500 total points
ID: 39223118
When you have 2 multi-element criteria ranges in COUNTIFS one needs to be separated by commas and one by semi-colons (assuming UK/US regional settings), so if you change the last comma , to a semi-colon ; your original formula will work, i.e.

=SUM(COUNTIFS($P:$P, "Program Planning & Policy",$O:$O, {"AZ","CA","DC","IN","LA","ME","MI","NC","NY","PR","TX","VT","WA"},$S:$S, {"Reg.";"IS"}))

If you have 3 or more multi-element criteria you need to use something like NB_VC's suggestion

regards, barry
0
 
LVL 1

Author Closing Comment

by:-Polak
ID: 39223154
Thanks for the in-depth explaination of "why" and the cleaner solution.
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 23

Expert Comment

by:NBVC
ID: 39223177
Hey barry,

Thanks.. you taught me something too :)
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 39223259
Thanks, note that even if the criteria arrays are the same size like this:

=SUM(COUNTIFS(A:A,{"a","b","c"},B:B,{"x","y","z"}))

then with comma separators for both you will only count a/x, b/y and c/z combinations. To count all combinations you still need to have commas for one and semi-colons for the other like this:

=SUM(COUNTIFS(A:A,{"a";"b";"c"},B:B,{"x","y","z"}))

regards, barry
0
 
LVL 23

Expert Comment

by:NBVC
ID: 39223536
Oh, I see.  Thanks again for elaborating.  When I tested I got the correct result without realizing that they were aligned as you mentioned.  :)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Query Missing Money orders... 6 70
Excel 6 18
Formula to copy cell and its "format" 3 26
Excel Array formula issues 4 13
A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
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;…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
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.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now