countif condition problem

S

Scott

I am working with two rows of data, I want to count the number of times that
both rows are equal to a value I specify. Something like this COUNTIF(1:1,
AND(1:X="1", 2:X="0")). Given the table below, the formula should be equal to
two.

A B C D E F G H I J K
1 0 0 1 0 0 1 0 0 1 0 1
2 1 0 0 1 0 1 0 0 0 1 1
 
D

Domenic

Try...

=SUMPRODUCT(--(A1:K1=1),--(A2:K2=0))

Note that SUMPRODUCT does not accept whole column references.

Hope this helps!
 
B

Bob Phillips

=SUMPRODUCT(--(1:1=1),--(2:2=0),--(2:2<>""))

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
D

Domenic

....but as Bob has shown, it does accept whole row references. Also, I
should have included a third argument, like Bob did, to deal with blank
cells.
 
K

Kleev

Rather than speculate, I will ask, why do you need the 2:2<>""? I tried this
out, and found you do need it (if there is a 1 in row 1,) but if I say
anything else, I will be speculating.

Bob Phillips said:
=SUMPRODUCT(--(1:1=1),--(2:2=0),--(2:2<>""))

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
P

Peo Sjoblom

It's because blank cells return zero when evaluated thus to avoid blank
cells skewing the result when 0 is a condition one can either
check for number like in

=ISNUMBER(Range)

or not empty

=Range<>""


--

Regards,

Peo Sjoblom

Kleev said:
Rather than speculate, I will ask, why do you need the 2:2<>""? I tried this
out, and found you do need it (if there is a 1 in row 1,) but if I say
anything else, I will be speculating.
 
K

Kleev

Thanks for clearing that up.

Peo Sjoblom said:
It's because blank cells return zero when evaluated thus to avoid blank
cells skewing the result when 0 is a condition one can either
check for number like in

=ISNUMBER(Range)

or not empty

=Range<>""


--

Regards,

Peo Sjoblom
 
M

mjman15

i have a similar problem... here is my situation


OK i got these hours
A B
TED 14
BOB 23
GARY 32
LEW 15

Schedule errors: 1

Lets say that Gary and Bob are full time employees..so i need to mak
sure i schedule them at least 32 hours I need a function that wil
report in number format how many "schedule conflits" or "schedul
errors i have" i have meaning i have a full timer only scheduled 2
hours. i tried using =COUNTIF(B1:B4,">=0")-COUNTIF(B1:B4,">32")
Problem i had with that is it red flagged ANY employe who was not at 3
hours what i need it to do is ONLY look at say cell B2,B5,B10 and chec
to see if they are at least 32 hours. ...Hope this makes sense..thank
agai
 
B

Bob Phillips

Best to add another column with a flag to say full-timer or not, and then
use

=SUMPRODUCT(--(C:C="Y"),--(B:B<32))&" people under-scheduled"

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Top