PC Review


Reply
Thread Tools Rate Thread

Counting unique records in a field

 
 
Loris
Guest
Posts: n/a
 
      29th Nov 2008
In Excel 2003, I have a large list (database). In one of the fields I have
multiple company names. Each company may be listed many times. Is there a
way to count the number of different companies that are in that field? I
don't care how many times any one company appears, just how many different
companies there are.
 
Reply With Quote
 
 
 
 
Gary Mc
Guest
Posts: n/a
 
      29th Nov 2008
Loris,

=COUNTIF(RANGE,"COMPANY NAME") where "RANGE" contains the list of company
names should give you what you want.

"Loris" wrote:

> In Excel 2003, I have a large list (database). In one of the fields I have
> multiple company names. Each company may be listed many times. Is there a
> way to count the number of different companies that are in that field? I
> don't care how many times any one company appears, just how many different
> companies there are.

 
Reply With Quote
 
T. Valko
Guest
Posts: n/a
 
      29th Nov 2008
Try this:

If there might be empty cells and they are to be excluded:

=SUMPRODUCT((A1:A100<>"")/COUNTIF(A1:A100,A1:A100&""))

If there will not be empty cells:

=SUMPRODUCT(1/COUNTIF(A1:A100,A1:A100))

Note that these are slow to calculate on large amounts of data (1000's of
rows).

--
Biff
Microsoft Excel MVP


"Loris" <(E-Mail Removed)> wrote in message
news:E2E46A97-2163-4926-9A62-(E-Mail Removed)...
> In Excel 2003, I have a large list (database). In one of the fields I have
> multiple company names. Each company may be listed many times. Is there
> a
> way to count the number of different companies that are in that field? I
> don't care how many times any one company appears, just how many different
> companies there are.



 
Reply With Quote
 
Gary Mc
Guest
Posts: n/a
 
      29th Nov 2008
Loris,

I apologize for my earlier response as it was incorrect; I misread your
request.

GMc

"Loris" wrote:

> In Excel 2003, I have a large list (database). In one of the fields I have
> multiple company names. Each company may be listed many times. Is there a
> way to count the number of different companies that are in that field? I
> don't care how many times any one company appears, just how many different
> companies there are.

 
Reply With Quote
 
Lars-Åke Aspelin
Guest
Posts: n/a
 
      29th Nov 2008
Don't know if it will speed up anything, but you can replace
SUMPRODUCT with SUM in these two formulas.

Lars-Åke

On Sat, 29 Nov 2008 14:31:45 -0500, "T. Valko"
<(E-Mail Removed)> wrote:

>Try this:
>
>If there might be empty cells and they are to be excluded:
>
>=SUMPRODUCT((A1:A100<>"")/COUNTIF(A1:A100,A1:A100&""))
>
>If there will not be empty cells:
>
>=SUMPRODUCT(1/COUNTIF(A1:A100,A1:A100))
>
>Note that these are slow to calculate on large amounts of data (1000's of
>rows).


 
Reply With Quote
 
Loris
Guest
Posts: n/a
 
      29th Nov 2008
This is exactly what I needed. I wasn't familiar with the SUMPRODUCT
function. Now I have to figure out what it is doing so I can understand why
it works. Thanks much.

"T. Valko" wrote:

> Try this:
>
> If there might be empty cells and they are to be excluded:
>
> =SUMPRODUCT((A1:A100<>"")/COUNTIF(A1:A100,A1:A100&""))
>
> If there will not be empty cells:
>
> =SUMPRODUCT(1/COUNTIF(A1:A100,A1:A100))
>
> Note that these are slow to calculate on large amounts of data (1000's of
> rows).
>
> --
> Biff
> Microsoft Excel MVP
>
>
> "Loris" <(E-Mail Removed)> wrote in message
> news:E2E46A97-2163-4926-9A62-(E-Mail Removed)...
> > In Excel 2003, I have a large list (database). In one of the fields I have
> > multiple company names. Each company may be listed many times. Is there
> > a
> > way to count the number of different companies that are in that field? I
> > don't care how many times any one company appears, just how many different
> > companies there are.

>
>
>

 
Reply With Quote
 
Shane Devenshire
Guest
Posts: n/a
 
      29th Nov 2008
Hi,

1. Gary - Your idea can be modified as follow, provided there are no spaces:

=SUMPRODUCT(1/COUNTIF(A1:A10,A1:A10))

2. Antares - to understand the formula select a portion of the formula on
the formula bar, such as COUNTIF(A1:A10,A1:A10) and press the F9 key.
Examine the results and press Esc. test another complete piece...

If this helps, please click the Yes button

Cheers,
Shane Devenshire



"Gary Mc" wrote:

> Loris,
>
> I apologize for my earlier response as it was incorrect; I misread your
> request.
>
> GMc
>
> "Loris" wrote:
>
> > In Excel 2003, I have a large list (database). In one of the fields I have
> > multiple company names. Each company may be listed many times. Is there a
> > way to count the number of different companies that are in that field? I
> > don't care how many times any one company appears, just how many different
> > companies there are.

 
Reply With Quote
 
Shane Devenshire
Guest
Posts: n/a
 
      29th Nov 2008
Hi,

If you know there are going to be blanks in your range then you can use:
=SUMPRODUCT(1/COUNTIF(A3:A19,A3:A19&""))-1
if there won't be any blanks for sure then
=SUMPRODUCT(1/COUNTIF(A3:A19,A3:A19))
but if you don't know it's better to use the previously suggested formula.

If this helps, please click the Yes button

Cheers,
Shane Devenshire


"Loris" wrote:

> In Excel 2003, I have a large list (database). In one of the fields I have
> multiple company names. Each company may be listed many times. Is there a
> way to count the number of different companies that are in that field? I
> don't care how many times any one company appears, just how many different
> companies there are.

 
Reply With Quote
 
Shane Devenshire
Guest
Posts: n/a
 
      29th Nov 2008
Hi Lars,

SUMPRODUCT is faster than SUM array entered. It might only be 15-25% faster
but its something.

If this helps, please click the Yes button

Cheers,
Shane Devenshire

"Lars-Ã…ke Aspelin" wrote:

> Don't know if it will speed up anything, but you can replace
> SUMPRODUCT with SUM in these two formulas.
>
> Lars-Ã…ke
>
> On Sat, 29 Nov 2008 14:31:45 -0500, "T. Valko"
> <(E-Mail Removed)> wrote:
>
> >Try this:
> >
> >If there might be empty cells and they are to be excluded:
> >
> >=SUMPRODUCT((A1:A100<>"")/COUNTIF(A1:A100,A1:A100&""))
> >
> >If there will not be empty cells:
> >
> >=SUMPRODUCT(1/COUNTIF(A1:A100,A1:A100))
> >
> >Note that these are slow to calculate on large amounts of data (1000's of
> >rows).

>
>

 
Reply With Quote
 
T. Valko
Guest
Posts: n/a
 
      29th Nov 2008
In this application the SUM array is marginally faster than SUMPRODUCT.

=SUMPRODUCT((A1:A1000<>"")/COUNTIF(A1:A1000,A1:A1000&""))

Average calc time (5 calculations): 0.063036 seconds

=SUM((A1:A1000<>"")/COUNTIF(A1:A1000,A1:A1000&""))

Average calc time (5 calculations): 0.062782 seconds

=SUMPRODUCT(1/COUNTIF(A1:A1000,A1:A1000))

Average calc time (5 calculations): 0.31791 seconds

=SUM(1/COUNTIF(A1:A1000,A1:A1000))

Average calc time (5 calculations): 0.316408 seconds

Calc times measured using Charles Williams' RangeTimer method.

--
Biff
Microsoft Excel MVP


"Lars-Åke Aspelin" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Don't know if it will speed up anything, but you can replace
> SUMPRODUCT with SUM in these two formulas.
>
> Lars-Åke
>
> On Sat, 29 Nov 2008 14:31:45 -0500, "T. Valko"
> <(E-Mail Removed)> wrote:
>
>>Try this:
>>
>>If there might be empty cells and they are to be excluded:
>>
>>=SUMPRODUCT((A1:A100<>"")/COUNTIF(A1:A100,A1:A100&""))
>>
>>If there will not be empty cells:
>>
>>=SUMPRODUCT(1/COUNTIF(A1:A100,A1:A100))
>>
>>Note that these are slow to calculate on large amounts of data (1000's of
>>rows).

>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reporting and Counting Unique Records RobFJ Microsoft Access Queries 1 3rd Mar 2009 02:22 PM
Counting unique records jj Microsoft Access 9 10th Apr 2008 11:36 PM
Counting unique records =?Utf-8?B?eWh0YWs=?= Microsoft Excel Worksheet Functions 6 16th Jun 2006 02:34 PM
Help with query counting unique records??? =?Utf-8?B?RmlsZWQ=?= Microsoft Access Queries 12 4th Apr 2005 03:01 PM
Counting Unique Records Andy Microsoft Excel Programming 2 14th Oct 2004 11:34 AM


Features
 

Advertising
 

Newsgroups
 


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