A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

"COUNTU" function in Excel to count unique entries in a range



 
 
Thread Tools Display Modes
  #1  
Old June 2nd, 2005, 01:10 AM
WayneL
external usenet poster
 
Posts: n/a
Default "COUNTU" function in Excel to count unique entries in a range

In order to count the number of unique entries in a range of cells, a very
complicated nested set of functions (SUM, IF, FREQUENCY, MATCH, LEN, etc.) is
required in Excel.

I suggest adding a COUNTU worksheet function that would automatically count
the number of unique data entries. It should have options for counting
numbers, numbers + text, excluding blank cells, etc.

Thanks,
Wayne

----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.

http://www.microsoft.com/office/comm...et.f unctions
  #2  
Old June 2nd, 2005, 01:28 AM
Biff
external usenet poster
 
Posts: n/a
Default

Hi!

In order to count the number of unique entries in a range of cells, a very
complicated nested set of functions (SUM, IF, FREQUENCY, MATCH, LEN, etc.)
is
required in Excel.


Not really!

=SUMPRODUCT((A1:A15"")/COUNTIF(A1:A15,A1:A15&""))

Biff

"WayneL" wrote in message
...
In order to count the number of unique entries in a range of cells, a very
complicated nested set of functions (SUM, IF, FREQUENCY, MATCH, LEN, etc.)
is
required in Excel.

I suggest adding a COUNTU worksheet function that would automatically
count
the number of unique data entries. It should have options for counting
numbers, numbers + text, excluding blank cells, etc.

Thanks,
Wayne

----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow
this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.

http://www.microsoft.com/office/comm...et.f unctions



  #3  
Old June 2nd, 2005, 02:20 AM
Alan Beban
external usenet poster
 
Posts: n/a
Default

Or, if the functions in the freely downloadable file at
http:/home.pacbell.net/beban are available to your workbook

=ArrayCount(ArrayUniques(a1:a15))

Alan Beban

Biff wrote:
Hi!


In order to count the number of unique entries in a range of cells, a very
complicated nested set of functions (SUM, IF, FREQUENCY, MATCH, LEN, etc.)
is
required in Excel.



Not really!

=SUMPRODUCT((A1:A15"")/COUNTIF(A1:A15,A1:A15&""))

Biff

"WayneL" wrote in message
...

In order to count the number of unique entries in a range of cells, a very
complicated nested set of functions (SUM, IF, FREQUENCY, MATCH, LEN, etc.)
is
required in Excel.

I suggest adding a COUNTU worksheet function that would automatically
count
the number of unique data entries. It should have options for counting
numbers, numbers + text, excluding blank cells, etc.

Thanks,
Wayne

----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow
this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.

http://www.microsoft.com/office/comm...et.f unctions




  #4  
Old June 2nd, 2005, 08:55 AM
Aladin Akyurek
external usenet poster
 
Posts: n/a
Default

WayneL wrote:
In order to count the number of unique entries in a range of cells, a very
complicated nested set of functions (SUM, IF, FREQUENCY, MATCH, LEN, etc.) is
required in Excel.

I suggest adding a COUNTU worksheet function that would automatically count
the number of unique data entries. It should have options for counting
numbers, numbers + text, excluding blank cells, etc.

Thanks,
Wayne

----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.

http://www.microsoft.com/office/comm...et.f unctions


A good candidate is Longre's (updated) COUNTDIFF from his morefunc add-in.
  #5  
Old June 2nd, 2005, 10:20 AM
KL
external usenet poster
 
Posts: n/a
Default

Hi,

I also use these versions of the formula posted by Biff:

=SUMPRODUCT((ISNUMBER(A1:A15)+ISTEXT(A1:A15))/COUNTIF(A1:A15,A1:A15&""))

=SUMPRODUCT((ISNUMBER(A1:A15)+ISTEXT(A1:A15)+ISLOG ICAL(A1:A15)/COUNTIF(A1:A15,A1:A15&""))

=SUMPRODUCT((ISNUMBER(A1:A15)+ISTEXT(A1:A15)+ISLOG ICAL(A1:A15)+ISERROR(A1:A15))/COUNTIF(A1:A15,A1:A15&""))

which give a lot of flexibility in what to count and are "error-tolerant".
You just take out the types you don't want to be counted.

I couldn't however figure out how to combine 'error-tolerance' and counting
in the "blank" cells as there may be "" returned by formulas which are not
recognised by ISBLANK function.

I do recognize they may become a bit long, but they don't seem to be too
complex and again they are quite flexible.

Regards,
KL



"Biff" wrote in message
...
Hi!

In order to count the number of unique entries in a range of cells, a
very
complicated nested set of functions (SUM, IF, FREQUENCY, MATCH, LEN,
etc.) is
required in Excel.


Not really!

=SUMPRODUCT((A1:A15"")/COUNTIF(A1:A15,A1:A15&""))

Biff

"WayneL" wrote in message
...
In order to count the number of unique entries in a range of cells, a
very
complicated nested set of functions (SUM, IF, FREQUENCY, MATCH, LEN,
etc.) is
required in Excel.

I suggest adding a COUNTU worksheet function that would automatically
count
the number of unique data entries. It should have options for counting
numbers, numbers + text, excluding blank cells, etc.

Thanks,
Wayne

----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the
"I
Agree" button in the message pane. If you do not see the button, follow
this
link to open the suggestion in the Microsoft Web-based Newsreader and
then
click "I Agree" in the message pane.

http://www.microsoft.com/office/comm...et.f unctions





  #6  
Old June 2nd, 2005, 08:44 PM
Harlan Grove
external usenet poster
 
Posts: n/a
Default

Alan Beban wrote...
Or, if the functions in the freely downloadable file at
http:/home.pacbell.net/beban are available to your workbook

=ArrayCount(ArrayUniques(a1:a15))

....

Someone's got to ask, why use ArrayCount rather than the
built-in COUNTA function, as in

=COUNTA(ArrayUniques(A1:A15))

?

But more to the point, if all one wants to do is *COUNT*
the distinct entries in a range, why would one ever want
to use a slow udf rather than the much faster

=SUMPRODUCT((A1:A15"")/COUNTIF(A1:A15,A1:A15&""))

?

  #7  
Old June 3rd, 2005, 08:59 PM
Alan Beban
external usenet poster
 
Posts: n/a
Default

Harlan Grove wrote:
Alan Beban wrote...

Or, if the functions in the freely downloadable file at
http:/home.pacbell.net/beban are available to your workbook

=ArrayCount(ArrayUniques(a1:a15))


...

Someone's got to ask, why use ArrayCount rather than the
built-in COUNTA function, as in

=COUNTA(ArrayUniques(A1:A15))

?

But more to the point, if all one wants to do is *COUNT*
the distinct entries in a range, why would one ever want
to use a slow udf rather than the much faster

=SUMPRODUCT((A1:A15"")/COUNTIF(A1:A15,A1:A15&""))

?

None of the above suggestions deals with *all* of the OP's specs, which
Harlan Grove omitted in his post.

"It should have options for counting
numbers, numbers + text, excluding blank cells, etc."

For whatever it may be worth

=ArrayCount(ArrayUniques(a1:a15)) returns the number of unique entries
excluding blanks; =ArrayCount(ArrayUniques(a1:a15,,,False) returns the
number of unique entries including blanks.

=COUNTA(ArrayUniques(A1:A15)and =COUNTA(ArrayUniques(A1:A15),,,False)
both return the number of unique entries excluding blanks.

Additional suggestions would be required to deal with *all* the OP's specs.

Alan Beban
  #8  
Old June 3rd, 2005, 11:15 PM
Harlan Grove
external usenet poster
 
Posts: n/a
Default

Alan Beban wrote...
Harlan Grove wrote:

....
But more to the point, if all one wants to do is *COUNT*
the distinct entries in a range, why would one ever want
to use a slow udf rather than the much faster

=SUMPRODUCT((A1:A15"")/COUNTIF(A1:A15,A1:A15&""))

?


None of the above suggestions deals with *all* of the OP's specs, which
Harlan Grove omitted in his post.

"It should have options for counting numbers, numbers + text, excluding
blank cells, etc."

For whatever it may be worth

=ArrayCount(ArrayUniques(a1:a15)) returns the number of unique entries
excluding blanks; =ArrayCount(ArrayUniques(a1:a15,,,False) returns the
number of unique entries including blanks.


Missing a right parenthesis on that second formula.

=COUNTA(ArrayUniques(A1:A15)and =COUNTA(ArrayUniques(A1:A15),,,False)
both return the number of unique entries excluding blanks.

....

Missing another right parenthesis on the first formula and looks like a
prematute right parenthesis in the second formula.

Fine. =ROWS(ArrayUniques(A1:A15)) returns the distinct count excluding
blanks, and =ROWS(ArrayUniques(A1:A15,,,FALSE)) returns the distinct
count including blanks.

To count only distinct numbers in Rng,

=SUMPRODUCT(ISNUMBER(Rng)/COUNTIF(Rng,Rng&""))


To count only distinct text including "" in Rng,

=SUMPRODUCT(ISTEXT(Rng)/COUNTIF(Rng,Rng&""))


To count only distinct text excluding "" in Rng,

=SUMPRODUCT(ISTEXT(Rng)*ISNUMBER(1/(Rng""))/COUNTIF(Rng,Rng&""))


To count distinct error values in Rng,

=SUMPRODUCT(ISERROR(Rng)/COUNTIF(Rng,Rng&""))


To count distinct logical values in Rng,

=SUMPRODUCT(ISLOGICAL(Rng)/COUNTIF(Rng,Rng&""))


To count distinct positive numbers in range,

=SUMPRODUCT(ISNUMBER(Rng)*ISNUMBER(1/(Rng0))/COUNTIF(Rng,Rng&""))


To count distinct numbers or text in Rng,

=SUMPRODUCT((ISNUMBER(Rng)+ISTEXT(Rng))/COUNTIF(Rng,Rng&""))


Are we getting the point yet?


Since ArrayUniques has the function definition

Function ArrayUniques(InputArray, _
Optional MatchCase As Boolean = True, _
Optional Base_Orient As String = "1vert", _
Optional OmitBlanks As Boolean = True)

I can see how it could include or exclude blanks, but how would one
need to call it to count distinct numbers or text in ranges that could
also include booleans and errors?

  #9  
Old June 4th, 2005, 07:48 PM
Alan Beban
external usenet poster
 
Posts: n/a
Default

Harlan Grove wrote:
. . .
But more to the point, if all one wants to do is *COUNT*
the distinct entries in a range, why would one ever want
to use a slow udf rather than the much faster

=SUMPRODUCT((A1:A15"")/COUNTIF(A1:A15,A1:A15&""))

?

Because the range may contain error values.

Alan Beban
  #10  
Old June 4th, 2005, 08:08 PM
Alan Beban
external usenet poster
 
Posts: n/a
Default

Harlan Grove wrote:
. . .

To count only distinct text including "" in Rng,

=SUMPRODUCT(ISTEXT(Rng)/COUNTIF(Rng,Rng&""))
. . .
To count distinct numbers or text in Rng,

=SUMPRODUCT((ISNUMBER(Rng)+ISTEXT(Rng))/COUNTIF(Rng,Rng&""))


Are we getting the point yet?

. . . .


Neither of the above works if the range includes blank cells (as
contrasted with cells that contain the empty string).

Alan Beban
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Conversion SVC Worksheet Functions 9 February 28th, 2005 02:29 PM
Return a count of unique entries? Tony Running & Setting Up Queries 2 February 3rd, 2005 04:50 PM
Pivot Table Access 2000? Air-ron General Discussion 2 October 29th, 2004 06:19 PM


All times are GMT +1. The time now is 12:20 AM.


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