Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 48
Default Count if, excluding zeros

Hi,

What I'm trying to do is, in one cell, get a count of unique values in
a column that, in the adjacent column, do not have a value of 0.

For instance, if my table looked like this:

A 1
A 1
B 1
B 1
B 1
C 0
C 0
D 1

I'd want a formula that would give me the value of 3, such that it
counts how many unique values there are in the first column and then,
if the sum of that unique value is 0, it excludes it from the count.

I could do this in a third column, by putting the formula:
=IF(OR(B3=B2,C3=0),D2,D2+1) (assuming the first "A" is in cell B3),
and then dropping that down and taking the max value, however, I'd
like to do this in one cell.

Is this possible, perhaps using an array? I'm already using {=SUM(1/
COUNTIF($B$3:$B$12,$B$3:$B$12))} to get me the unique value count, but
can't figure out how to exclude the ones with a total of 0.

Thanks in advance!

Brett
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default Count if, excluding zeros

=SUM(--(FREQUENCY(IF(B1:B20<0,MATCH(A1:A20,A1:A20,0)),RO W(INDIRECT("1:"&ROWS(A1:A20))))0))

which is an array formula, Ctrl-Shift-Enter, not just Enter

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



wrote in message
...
Hi,

What I'm trying to do is, in one cell, get a count of unique values in
a column that, in the adjacent column, do not have a value of 0.

For instance, if my table looked like this:

A 1
A 1
B 1
B 1
B 1
C 0
C 0
D 1

I'd want a formula that would give me the value of 3, such that it
counts how many unique values there are in the first column and then,
if the sum of that unique value is 0, it excludes it from the count.

I could do this in a third column, by putting the formula:
=IF(OR(B3=B2,C3=0),D2,D2+1) (assuming the first "A" is in cell B3),
and then dropping that down and taking the max value, however, I'd
like to do this in one cell.

Is this possible, perhaps using an array? I'm already using {=SUM(1/
COUNTIF($B$3:$B$12,$B$3:$B$12))} to get me the unique value count, but
can't figure out how to exclude the ones with a total of 0.

Thanks in advance!

Brett



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 48
Default Count if, excluding zeros

That works - thanks!!

By the way, what does the "--" before the frequency mean?

Thanks!
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default Count if, excluding zeros

It is used to coerce TRUE/FALSE values to 1/0. The FREQUENCY(..)0 will
return an array of TRUE and FALSE values, the first - coerces this to an
array of -1/0, the second negates it to an array of 1/0, and SUM then just
adds them up.

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



wrote in message
...
That works - thanks!!

By the way, what does the "--" before the frequency mean?

Thanks!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Average percentage excluding zeros spanning numerous tabs Willabo Excel Discussion (Misc queries) 5 July 31st 06 04:02 PM
Averages excluding zeros Jaytee Excel Discussion (Misc queries) 3 July 16th 06 04:26 PM
Most frequent item in a list (excluding zeros) Andre Croteau Excel Discussion (Misc queries) 3 November 12th 05 06:58 PM
Average, Excluding Zeros, Non-Consecutive Range Coal Miner Excel Discussion (Misc queries) 9 August 4th 05 10:21 PM
EXcluding Zeros from the average in a row Geo Excel Discussion (Misc queries) 4 December 31st 04 04:07 PM


All times are GMT +1. The time now is 12:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"