Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Worksheet Functions / October 2006

Tip: Looking for answers? Try searching our database.

Formula to count numbers

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Epinn - 30 Oct 2006 00:28 GMT
A1:A9

1,2,3,8,-9,0,null (i.e.=""),blank,8

I want to count the numbers (both positive and negative) but I want to exclude 0, null and blank.  Duplicates are counted more than once.

The formula I come up with is

=SUMPRODUCT((A1:A9<>0)*(A1:A9<>""))

It gives me the correct result of 6.  

I also play with the following formula

=SUMPRODUCT((A1:A9<>0)*(A1:A9<>"")*(A1:A9>0)+(A1:A9<0))

I do "evaluate formula" to see how 0, null, blank etc. are treated.  To my surprise, null is considered greater than 0 but blank is not.  Can someone do "evaluate formula" and tell me that I am not seeing things?

Why is null > 0?  Is it considered "text?"

Please shed some light on this.  Thanks.  

I am still having a bit of a problem coming up with a simple formula using COUNTIF or COUNT.  What do I do without you, SUMPRODUCT?

Epinn
Epinn - 30 Oct 2006 00:51 GMT
If I use COUNTIF, my formula will be like this.

=SUM(COUNTIF(A1:A9,{">0","<0"}))

Interestingly enough, null is not >0 when I use COUNTIF.

If I use =COUNTIF(A1:A9,"<>0") I get 8 instead of 6 because blanks are counted.

I am still quite confused with zero, null and blank.  I feel that I have to do different logical test(s) depending on which function I use, or if I use Boolean.  Is there an easier way (e.g. one fits all formula) to apply to all this?

Help!

A1:A9

1,2,3,8,-9,0,null (i.e.=""),blank,8

I want to count the numbers (both positive and negative) but I want to exclude 0, null and blank.  Duplicates are counted more than once.

The formula I come up with is

=SUMPRODUCT((A1:A9<>0)*(A1:A9<>""))

It gives me the correct result of 6.  

I also play with the following formula

=SUMPRODUCT((A1:A9<>0)*(A1:A9<>"")*(A1:A9>0)+(A1:A9<0))

I do "evaluate formula" to see how 0, null, blank etc. are treated.  To my surprise, null is considered greater than 0 but blank is not.  Can someone do "evaluate formula" and tell me that I am not seeing things?

Why is null > 0?  Is it considered "text?"

Please shed some light on this.  Thanks.  

I am still having a bit of a problem coming up with a simple formula using COUNTIF or COUNT.  What do I do without you, SUMPRODUCT?

Epinn
Epinn - 30 Oct 2006 01:10 GMT
Correction

>> If I use =COUNTIF(A1:A9,"<>0") I get 8 instead of 6 because blanks are counted. <<

8-6=2  2 is made up by a blank and a null string.  As discussed previously, there doesn't seem to be a way to differentiate between blank and null when COUNTIF is used.

Roger, sometimes blank is treated as zero and sometimes it is not even for the same function COUNTIF.  In other words, I have to do trial an error and very detailed testing for each function for each purpose (count vs. checking for duplicates), when it comes to zero, null and blank.

If I use COUNTIF, my formula will be like this.

=SUM(COUNTIF(A1:A9,{">0","<0"}))

Interestingly enough, null is not >0 when I use COUNTIF.

If I use =COUNTIF(A1:A9,"<>0") I get 8 instead of 6 because blanks are counted.

I am still quite confused with zero, null and blank.  I feel that I have to do different logical test(s) depending on which function I use, or if I use Boolean.  Is there an easier way (e.g. one fits all formula) to apply to all this?

Help!

Epinn

"Epinn" <someone@example.com.NO_SPAM> wrote in message news:ucbliJ7#GHA.1224@TK2MSFTNGP04.phx.gbl...
A1:A9

1,2,3,8,-9,0,null (i.e.=""),blank,8

I want to count the numbers (both positive and negative) but I want to exclude 0, null and blank.  Duplicates are counted more than once.

The formula I come up with is

=SUMPRODUCT((A1:A9<>0)*(A1:A9<>""))

It gives me the correct result of 6.  

I also play with the following formula

=SUMPRODUCT((A1:A9<>0)*(A1:A9<>"")*(A1:A9>0)+(A1:A9<0))

I do "evaluate formula" to see how 0, null, blank etc. are treated.  To my surprise, null is considered greater than 0 but blank is not.  Can someone do "evaluate formula" and tell me that I am not seeing things?

Why is null > 0?  Is it considered "text?"

Please shed some light on this.  Thanks.  

I am still having a bit of a problem coming up with a simple formula using COUNTIF or COUNT.  What do I do without you, SUMPRODUCT?

Epinn
JMB - 30 Oct 2006 01:48 GMT
This seemed to work
=SUM(--(IF(ISNUMBER(A1:A8),A1:A8,)<>0))
Array entered

> A1:A9
>
[quoted text clipped - 21 lines]
>
> Epinn
Epinn - 30 Oct 2006 02:47 GMT
JMB,

Thanks for the formula.  I did experiment with ISNUMBER and <>0 in the same formula, but no luck.  Why?  I used IF(COUNT( etc. and I got lost.  I changed your formula to >=0 and it picked up the blank and the null even though ISNUMBER is in the formula.  Why?  FALSE = 0.  

=COUNTIF(A1:A9,">0") gives me 5.
=A1>0 and copied down in column B.  I have got 6 TRUE.

This proves that I am not seeing things with evaluate formula.  NULL is treated as >0.

Looks like SUMPRODUCT is the one function I am willing to trust.

Epinn

This seemed to work
=SUM(--(IF(ISNUMBER(A1:A8),A1:A8,)<>0))
Array entered

"Epinn" wrote:

> A1:A9
>
[quoted text clipped - 21 lines]
>
> Epinn
JMB - 30 Oct 2006 03:57 GMT
=SUM(--(IF(ISNUMBER(A1:A8),A1:A8,)>0))

gives me 4.  Did you put the "," in the 3 argument of the IF function.  It's
the same as:

=SUM(--(IF(ISNUMBER(A1:A8),A1:A8,0)>0))

> JMB,
>
[quoted text clipped - 40 lines]
> >
> > Epinn
Epinn - 30 Oct 2006 04:30 GMT
JMB,

Firstly, please change your formula to A1:A9 for my data set so that we are talking about the same thing.

There is nothing wrong with your formula when we use >0 or <>0.  I get the correct result of 5 and 6 respectively.  

If you reread my previous post again, you will note that I was playing with >= (i.e. greater than and equal to) 0.  This is where we can have a problem.

Blank and null are counted even though ISNUMBER is used.  This is because FALSE is translated to 0.

Epinn

=SUM(--(IF(ISNUMBER(A1:A8),A1:A8,)>0))

gives me 4.  Did you put the "," in the 3 argument of the IF function.  It's
the same as:

=SUM(--(IF(ISNUMBER(A1:A8),A1:A8,0)>0))

"Epinn" wrote:

> JMB,
>
[quoted text clipped - 39 lines]
> >
> > Epinn
Biff - 30 Oct 2006 02:58 GMT
>Why is null > 0?  Is it considered "text?"

Yes. ="" is an empty TEXT string. A TEXT value will always evaluate to be
greater than ANY number.

Biff

A1:A9

1,2,3,8,-9,0,null (i.e.=""),blank,8

I want to count the numbers (both positive and negative) but I want to
exclude 0, null and blank.  Duplicates are counted more than once.

The formula I come up with is

=SUMPRODUCT((A1:A9<>0)*(A1:A9<>""))

It gives me the correct result of 6.

I also play with the following formula

=SUMPRODUCT((A1:A9<>0)*(A1:A9<>"")*(A1:A9>0)+(A1:A9<0))

I do "evaluate formula" to see how 0, null, blank etc. are treated.  To my
surprise, null is considered greater than 0 but blank is not.  Can someone
do "evaluate formula" and tell me that I am not seeing things?

Why is null > 0?  Is it considered "text?"

Please shed some light on this.  Thanks.

I am still having a bit of a problem coming up with a simple formula using
COUNTIF or COUNT.  What do I do without you, SUMPRODUCT?

Epinn
Biff - 30 Oct 2006 03:05 GMT
=COUNT(A1:A9)-COUNTIF(A1:A9,0)

Biff

A1:A9

1,2,3,8,-9,0,null (i.e.=""),blank,8

I want to count the numbers (both positive and negative) but I want to
exclude 0, null and blank.  Duplicates are counted more than once.

The formula I come up with is

=SUMPRODUCT((A1:A9<>0)*(A1:A9<>""))

It gives me the correct result of 6.

I also play with the following formula

=SUMPRODUCT((A1:A9<>0)*(A1:A9<>"")*(A1:A9>0)+(A1:A9<0))

I do "evaluate formula" to see how 0, null, blank etc. are treated.  To my
surprise, null is considered greater than 0 but blank is not.  Can someone
do "evaluate formula" and tell me that I am not seeing things?

Why is null > 0?  Is it considered "text?"

Please shed some light on this.  Thanks.

I am still having a bit of a problem coming up with a simple formula using
COUNTIF or COUNT.  What do I do without you, SUMPRODUCT?

Epinn
Epinn - 30 Oct 2006 03:28 GMT
I like that.  So simple.  Wish we could have something even shorter.

When we have COUNT and COUNTA, we shoud be provided with COUNTIF and COUNTAIF.  Then I don't have to do any subtraction.  Don't think this happens in V. 2007.

Please tell me if you'll use the SUMPRODUCT formula or this COUNT/COUNTIF formula for your work.  My preference is SUMPRODUCT for me.

Thanks, Biff.

Epinn

=COUNT(A1:A9)-COUNTIF(A1:A9,0)

Biff

A1:A9

1,2,3,8,-9,0,null (i.e.=""),blank,8

I want to count the numbers (both positive and negative) but I want to
exclude 0, null and blank.  Duplicates are counted more than once.

The formula I come up with is

=SUMPRODUCT((A1:A9<>0)*(A1:A9<>""))

It gives me the correct result of 6.

I also play with the following formula

=SUMPRODUCT((A1:A9<>0)*(A1:A9<>"")*(A1:A9>0)+(A1:A9<0))

I do "evaluate formula" to see how 0, null, blank etc. are treated.  To my
surprise, null is considered greater than 0 but blank is not.  Can someone
do "evaluate formula" and tell me that I am not seeing things?

Why is null > 0?  Is it considered "text?"

Please shed some light on this.  Thanks.

I am still having a bit of a problem coming up with a simple formula using
COUNTIF or COUNT.  What do I do without you, SUMPRODUCT?

Epinn
Biff - 30 Oct 2006 03:46 GMT
>Please tell me if you'll use the SUMPRODUCT formula
>or this COUNT/COUNTIF formula for your work.

I will always use the simplest formula I can come up with at the time! A lot
of times I'll write a formula and 10 minutes later I'll have thought of a
better way to do it.

Biff

I like that.  So simple.  Wish we could have something even shorter.

When we have COUNT and COUNTA, we shoud be provided with COUNTIF and
COUNTAIF.  Then I don't have to do any subtraction.  Don't think this
happens in V. 2007.

Please tell me if you'll use the SUMPRODUCT formula or this COUNT/COUNTIF
formula for your work.  My preference is SUMPRODUCT for me.

Thanks, Biff.

Epinn

=COUNT(A1:A9)-COUNTIF(A1:A9,0)

Biff

"Epinn" <someone@example.com.NO_SPAM> wrote in message
news:ucbliJ7%23GHA.1224@TK2MSFTNGP04.phx.gbl...
A1:A9

1,2,3,8,-9,0,null (i.e.=""),blank,8

I want to count the numbers (both positive and negative) but I want to
exclude 0, null and blank.  Duplicates are counted more than once.

The formula I come up with is

=SUMPRODUCT((A1:A9<>0)*(A1:A9<>""))

It gives me the correct result of 6.

I also play with the following formula

=SUMPRODUCT((A1:A9<>0)*(A1:A9<>"")*(A1:A9>0)+(A1:A9<0))

I do "evaluate formula" to see how 0, null, blank etc. are treated.  To my
surprise, null is considered greater than 0 but blank is not.  Can someone
do "evaluate formula" and tell me that I am not seeing things?

Why is null > 0?  Is it considered "text?"

Please shed some light on this.  Thanks.

I am still having a bit of a problem coming up with a simple formula using
COUNTIF or COUNT.  What do I do without you, SUMPRODUCT?

Epinn
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.