Can I combine CountIf with IF or AND?

G

Gmolatore

Can I make the CountIf function conditional by preceding it with IF as follows:
=IF(O8:O264
0,(CountIF(M8:M264,"Issued",N8:N264)+CountIf(M8:M264,"Delivered",N8:N264))
This formula doesn't work, but you can see what I'm trying to do.
Alternatively to do the same thing using AND:
CountIF(AND((M8:M264,"Issued",O8:O264
0),N8:N264)+CountIf(AND((M8:M264,"Delivered",O8:O264 >0),N8:N264))
This also doesn't work. Any tips?
 
T

T. Valko

Are you wanting a count or a sum?

Here's the sum:

=SUMPRODUCT((M8:M264="Issued")+(M8:M264="Delivered"),--(O8:O264>0),N8:N264)

Here's the count:

=SUMPRODUCT((M8:M264="Issued")+(M8:M264="Delivered"),--(O8:O264>0))
 
G

Gmolatore

What's wrong with this?
=sumproduct(('Old Mutual'!$L$7:'Old Mutual'!$L$263,"=Issued")+('Old
Mutual'!$L$7:'Old Mutual'!$L$263,"=Delivered"),--('Old Mutual'!O7:'Old
Mutual'!O263=0))
 
T

T. Valko

Try it like this:

=SUMPRODUCT(('Old Mutual'!$L$7:$L$263="Issued")+('Old
Mutual'!$L$7:$L$263="Delivered"),--('Old Mutual'!$O$7:$O$263=0))

Note that empty cells will evaluate to =0. So you might have to add another
test:

=SUMPRODUCT(('Old Mutual'!$L$7:$L$263="Issued")+('Old
Mutual'!$L$7:$L$263="Delivered"),--(ISNUMBER('Old
Mutual'!$O$7:$O$263)),--('Old Mutual'!$O$7:$O$263=0))
 
G

Gmolatore

I get an Invalid Cell Reference warning when I use your formulas below.
Basically, I want the Countif functions to execute if the cells in Column O
are blank. Something like this (which doesn't work) =COUNTIF('Old
Mutual'!$L$7:'Old Mutual'!$L$263,"=Issued")+COUNTIF('Old Mutual'!$L$7:'Old
Mutual'!$L$263,"=Delivered")+ISBLANK('Old
Mutual'!$O$7:$O$263) For some reason, the CountIf function executes even
though cells in Column O are not blank.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top