Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
tjtjjtjt
 
Posts: n/a
Default counting unique items

I've seen formulas like this posted as a solution for counting unique items
in a column:
=SUMPRODUCT((A1:A20000<"")/COUNTIF(A1:A20000,A1:A20000&""))

What purpose does the &"" at the end serve?

--
tj
  #2   Report Post  
tjtjjtjt
 
Posts: n/a
Default

It seems to stop blanks in the range from causing the formula to return an
error message, but I'm not sure I see why.
--
tj


"tjtjjtjt" wrote:

I've seen formulas like this posted as a solution for counting unique items
in a column:
=SUMPRODUCT((A1:A20000<"")/COUNTIF(A1:A20000,A1:A20000&""))

What purpose does the &"" at the end serve?

--
tj

  #3   Report Post  
Biff
 
Posts: n/a
Default

Hi!

That's exactly what it does.

If a cell is blank, then:

A1:A20000<"" will return FALSE in that cells position in the array. Then:

COUNTIF(A1:A20000,A1:A20000) will return 0 for that empty cell. Then:

FALSE/0 will return #DIV/0!

So, the empty text string is used so that:

A1:A20000<"" will return TRUE, then:

TRUE/0 will return 0.

To see how this formula works, try this in a small test range:

Put some random entries in A1:A5.

In B1 enter this formula and copy down to B5:

=A1<""

In C1 enter this formula and copy down to C5:

=COUNTIF(A$1:A$5,A1&"")

In D1 enter this formula and copy down to D5:

=B1/C1

And finally, enter this formula in E1:

=SUM(D1:D5)

Try experimenting by putting dupes in A1:A5. Then try removing the empty
string from the Countif formulas and delete some of the entries in A1:A5.

See what happens!

Biff

"tjtjjtjt" wrote in message
...
It seems to stop blanks in the range from causing the formula to return an
error message, but I'm not sure I see why.
--
tj


"tjtjjtjt" wrote:

I've seen formulas like this posted as a solution for counting unique
items
in a column:
=SUMPRODUCT((A1:A20000<"")/COUNTIF(A1:A20000,A1:A20000&""))

What purpose does the &"" at the end serve?

--
tj



  #4   Report Post  
Biff
 
Posts: n/a
Default

Ooops!

I goofed in my explanation:

So, the empty text string is used so that:

A1:A20000<"" will return TRUE, then:

TRUE/0 will return 0.



Should be:

So, the empty text string is used so that when:

A1:A20000<"" returns FALSE

The Countif will count the empty string so that:

FALSE/1 will return 0

Biff

"Biff" wrote in message
...
Hi!

That's exactly what it does.

If a cell is blank, then:

A1:A20000<"" will return FALSE in that cells position in the array. Then:

COUNTIF(A1:A20000,A1:A20000) will return 0 for that empty cell. Then:

FALSE/0 will return #DIV/0!

So, the empty text string is used so that:

A1:A20000<"" will return TRUE, then:

TRUE/0 will return 0.

To see how this formula works, try this in a small test range:

Put some random entries in A1:A5.

In B1 enter this formula and copy down to B5:

=A1<""

In C1 enter this formula and copy down to C5:

=COUNTIF(A$1:A$5,A1&"")

In D1 enter this formula and copy down to D5:

=B1/C1

And finally, enter this formula in E1:

=SUM(D1:D5)

Try experimenting by putting dupes in A1:A5. Then try removing the empty
string from the Countif formulas and delete some of the entries in A1:A5.

See what happens!

Biff

"tjtjjtjt" wrote in message
...
It seems to stop blanks in the range from causing the formula to return
an
error message, but I'm not sure I see why.
--
tj


"tjtjjtjt" wrote:

I've seen formulas like this posted as a solution for counting unique
items
in a column:
=SUMPRODUCT((A1:A20000<"")/COUNTIF(A1:A20000,A1:A20000&""))

What purpose does the &"" at the end serve?

--
tj





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
Counting Unique text entries in a sheet with a condition Mike Excel Worksheet Functions 5 October 4th 05 11:56 AM
Counting Unique Cells When Spread Sheet is Filtered carl Excel Worksheet Functions 1 June 3rd 05 07:20 PM
Counting Unique Records with multiple conditions Keithlearn Excel Worksheet Functions 4 April 27th 05 12:44 AM
Counting unique entries in column A but only if specific values appear in columns B and C markx Excel Worksheet Functions 1 February 10th 05 11:52 AM
Count of unique items meeting condition Tim C Excel Worksheet Functions 1 November 12th 04 03:03 AM


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

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"