Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

USING COUNTIF WITH MULTIPLE CRITERIA

Posted on 2002-06-03
7
Medium Priority
?
943 Views
Last Modified: 2012-06-21
I want to be able to do a COUNTIF on 2 columns at the same time.  So in Column K, I have either a 1, 2 or 3.  In Column L, I have either a 1, 2 or 3.  I want it to count only those rows that have both a "1" in Columns K AND L.  Here's what I've tried, but these don't work.

=COUNTIF(K2:K34,"1")*AND(L2:L34,"1")   I get #VALUE

=COUNTIF(K2:K34,"1")*AND(COUNTIF(L2:L34,"1")) get error message

I've tried using the AND function, but am not sure how to use it with COUNTIF function, if I even can (?????).
0
Comment
Question by:esu4236
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 11

Expert Comment

by:LambertHeenan
ID: 7051652
Instead of CountIf try using a combination of IF() with AND() like this...

=IF(AND(K1=1,L1=1),1,"")

Then you can simply Sum the column with the If function to get the count of matching columns containing "1"
0
 

Author Comment

by:esu4236
ID: 7051713
Well, I really don't want to have to add yet another column.  Isn't there another way without doing this?
0
 
LVL 11

Expert Comment

by:LambertHeenan
ID: 7051880
IMHO columns are cheap, time is expensive. Off hand I don't see how you are going to do this using just COUNTIF().

The trouble is that COUNTIF() expects to check the value of every SINGLE cell in a range but you want to compare the values of two cells, so you need to have somewhere to store the results of that comparision before you can count them.

So either you use another column for the comparison result, or else you write your own function which will take a two column rage as it's imput parameter. The function would then compare each pare of cells within it's VBA code and store the intermediate results in a variable, which would then be used to return value of the function.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Accepted Solution

by:
bkpchs237 earned 400 total points
ID: 7051926
esu4236,

You could try an array formula, by entering the following into a cell and pressing ctrl+shift+enter to enter it as an array formula:
=SUM((K2:K34=1)*(L2:L34=1))

Hope this helps.
0
 

Author Comment

by:esu4236
ID: 7052051
Thank you very much BKPCHS237 for your solution.  That worked perfect!!!!!  I knew there had to be a way to do it without adding more columns.  Thanks again - you made my day!!!!!

0
 

Author Comment

by:esu4236
ID: 7052053
Thank you very much BKPCHS237 for your solution.  That worked perfect!!!!!  I knew there had to be a way to do it without adding more columns.  Thanks again - you made my day!!!!!

0
 
LVL 11

Expert Comment

by:LambertHeenan
ID: 7052179
bkpchs237 : as in infrequent user of Excel (I spend most of my days with Access) I am gratefull to you for your enlightening answer - Array functions have been something I've steered clear of before now.

0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
Microsoft has changed the look and feel of Azure AD and Microsoft account sign-in pages so that you will have a more unified look and feel when moving between the two interfaces.
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.

604 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