PC Review


Reply
Thread Tools Rate Thread

how to count only one instance of an item if multiple occurrences

 
 
A Newton
Guest
Posts: n/a
 
      15th Jan 2008
Hello,

I have an Excel 2003 spreadsheet. In column C of one of the
worksheets, there are numbers. In some cases, the numbers are unique
and appear only once in the column. For example, the number 348975
appears only once in the column in cell C45. But in other cases, there
are multiple instances of the same number. For example, 123456 appears
in C1, C2, C3, and C4. And 789012 might appear in C10, C150, and C334.

I am hoping someone can help me with this problem. I want to count all
instances of unique numbers in column C AND only one instance of each
number that has multiple instances. In other words, using the numbers
I gave as examples above, I would want to get a result of "3" (a count
of 348975, 123456, and 780912) rather than "8" (a count of C45, C1,
C2, C3, C4, C10, C150, and C334).

One thought I had was to have another column (Q) in the worksheet that
could basically identify each unique number with the number "1" and
then number multiple instance. I could then count only the items with
"1" in column Q. For example

C1 123456 1
C2 123456 2
C3 123456 3
C4 123456 4
C10 789012 1
C45 348975 1
C150 789012 2
C334 789012 3

Thanks in advance for your time and help.
 
Reply With Quote
 
 
 
 
JP
Guest
Posts: n/a
 
      15th Jan 2008
Here is an array formula that will do this.

=SUM(IF(FREQUENCY(A2:A10,A2:A10)>0,1))

Must be array-entered (Ctrl-Shift-Enter). Don't forget to replace
"A2:A10" with your actual range. This formula assumes that there are
only numbers in the range.

You could also used Advanced Filter (Data>Filter>Advanced Filter) to
create a list of unique items to another column.

HTH,
JP


On Jan 15, 11:36*am, A Newton <adamfnew...@gmail.com> wrote:
> Hello,
>
> I have an Excel 2003 spreadsheet. In column C of one of the
> worksheets, there are numbers. In some cases, the numbers are unique
> and appear only once in the column. For example, the number 348975
> appears only once in the column in cell C45. But in other cases, there
> are multiple instances of the same number. For example, 123456 appears
> in C1, C2, C3, and C4. And 789012 might appear in C10, C150, and C334.
>
> I am hoping someone can help me with this problem. I want to count all
> instances of unique numbers in column C AND only one instance of each
> number that has multiple instances. In other words, using the numbers
> I gave as examples above, I would want to get a result of "3" (a count
> of 348975, 123456, and 780912) rather than "8" (a count of C45, C1,
> C2, C3, C4, C10, C150, and C334).
>
> One thought I had was to have another column (Q) in the worksheet that
> could basically identify each unique number with the number "1" and
> then number multiple instance. I could then count only the items with
> "1" in column Q. For example
>
> C1 * * * * *123456 * * * * *1
> C2 * * * * *123456 * * * * *2
> C3 * * * * *123456 * * * * *3
> C4 * * * * *123456 * * * * *4
> C10 * * * * 789012 * * * * 1
> C45 * * * * 348975 * * * * 1
> C150 * * * *789012 * * * * 2
> C334 * * * *789012 * * * * 3
>
> Thanks in advance for your time and help.


 
Reply With Quote
 
A Newton
Guest
Posts: n/a
 
      15th Jan 2008
On Jan 15, 11:41 am, JP <jp2...@earthlink.net> wrote:
> Here is an array formula that will do this.
>
> =SUM(IF(FREQUENCY(A2:A10,A2:A10)>0,1))
>
> Must be array-entered (Ctrl-Shift-Enter). Don't forget to replace
> "A2:A10" with your actual range. This formula assumes that there are
> only numbers in the range.
>
> You could also used Advanced Filter (Data>Filter>Advanced Filter) to
> create a list of unique items to another column.
>
> HTH,
> JP
>
> On Jan 15, 11:36 am, A Newton <adamfnew...@gmail.com> wrote:
>
> > Hello,

>
> > I have an Excel 2003 spreadsheet. In column C of one of the
> > worksheets, there are numbers. In some cases, the numbers are unique
> > and appear only once in the column. For example, the number 348975
> > appears only once in the column in cell C45. But in other cases, there
> > are multiple instances of the same number. For example, 123456 appears
> > in C1, C2, C3, and C4. And 789012 might appear in C10, C150, and C334.

>
> > I am hoping someone can help me with this problem. I want to count all
> > instances of unique numbers in column C AND only one instance of each
> > number that has multiple instances. In other words, using the numbers
> > I gave as examples above, I would want to get a result of "3" (a count
> > of 348975, 123456, and 780912) rather than "8" (a count of C45, C1,
> > C2, C3, C4, C10, C150, and C334).

>
> > One thought I had was to have another column (Q) in the worksheet that
> > could basically identify each unique number with the number "1" and
> > then number multiple instance. I could then count only the items with
> > "1" in column Q. For example

>
> > C1 123456 1
> > C2 123456 2
> > C3 123456 3
> > C4 123456 4
> > C10 789012 1
> > C45 348975 1
> > C150 789012 2
> > C334 789012 3

>
> > Thanks in advance for your time and help.


JP,

Thanks! This is getting REALLY, REALLY CLOSE to what I need. It is not
exactly what I need only b/c because my examples were incomplete. My
fault entirely.

In many cases, the numbers in column C might start with a letter (v).
For example:

C1 v123456 1
C2 v123456 2
C3 v123456 3
C4 v123456 4
C10 789012 1
C45 348975 1
C150 789012 2
C334 789012 3
C53 v569802 1
C450 v569802 2

Any ideas?
 
Reply With Quote
 
feltra
Guest
Posts: n/a
 
      15th Jan 2008
Hi,

If you havent found the formula to populate cells in col Q based for
unique values in Col C, here's the formula that will do exactly as
you want. You can then simply count the 1s in col Q to get the unique
values in Col C:

In first row of data (say row 1) key in this formula in Col Q:
=COUNTIF($C$1:$C1,C1)

Highlight all the cells in Col Q from row1 to end of data row (say row
450 in your example). Then do a Fill Down (CTRL-D). The important
thing is to give the absolute and relative references exactly as shown
(ie. keying in the $ symbol or leaving it out).

The number of unique values in Col C can now be found by
=COUNTIF($Q$1:$Q$450,1)
in another results cell in the sheet.

This will work if you do it by hand... For putting in a macro (ie.
programming) you need a little more work, but can be done...

Hope this helps.

Best Regards,
-feltra

> Thanks! This is getting REALLY, REALLY CLOSE to what I need. It is not
> exactly what I need only b/c because my examples were incomplete. My
> fault entirely.
>
> In many cases, the numbers in column C might start with a letter (v).
> For example:
>
> C1 v123456 1
> C2 v123456 2
> C3 v123456 3
> C4 v123456 4
> C10 789012 1
> C45 348975 1
> C150 789012 2
> C334 789012 3
> C53 v569802 1
> C450 v569802 2
>
> Any ideas?


 
Reply With Quote
 
JP
Guest
Posts: n/a
 
      15th Jan 2008
=SUM(IF(FREQUENCY(IF(LEN(A2:A10)>0,MATCH(A2:A10,A2:A10,0),""),
IF(LEN(A2:A10)>0,MATCH(A2:A10,A2:A10,0),""))>0,1))

Replace "A2:A10" with your range, don't forget to ctrl-shift-enter.


HTH,
JP


On Jan 15, 12:03*pm, A Newton <adamfnew...@gmail.com> wrote:
> On Jan 15, 11:41 am, JP <jp2...@earthlink.net> wrote:
>
>
>
>
>
> > Here is an array formula that will do this.

>
> > =SUM(IF(FREQUENCY(A2:A10,A2:A10)>0,1))

>
> > Must be array-entered (Ctrl-Shift-Enter). Don't forget to replace
> > "A2:A10" with your actual range. This formula assumes that there are
> > only numbers in the range.

>
> > You could also used Advanced Filter (Data>Filter>Advanced Filter) to
> > create a list of unique items to another column.

>
> > HTH,
> > JP

>
> > On Jan 15, 11:36 am, A Newton <adamfnew...@gmail.com> wrote:

>
> > > Hello,

>
> > > I have an Excel 2003 spreadsheet. In column C of one of the
> > > worksheets, there are numbers. In some cases, the numbers are unique
> > > and appear only once in the column. For example, the number 348975
> > > appears only once in the column in cell C45. But in other cases, there
> > > are multiple instances of the same number. For example, 123456 appears
> > > in C1, C2, C3, and C4. And 789012 might appear in C10, C150, and C334.

>
> > > I am hoping someone can help me with this problem. I want to count all
> > > instances of unique numbers in column C AND only one instance of each
> > > number that has multiple instances. In other words, using the numbers
> > > I gave as examples above, I would want to get a result of "3" (a count
> > > of 348975, 123456, and 780912) rather than "8" (a count of C45, C1,
> > > C2, C3, C4, C10, C150, and C334).

>
> > > One thought I had was to have another column (Q) in the worksheet that
> > > could basically identify each unique number with the number "1" and
> > > then number multiple instance. I could then count only the items with
> > > "1" in column Q. For example

>
> > > C1 * * * * *123456 * * * * *1
> > > C2 * * * * *123456 * * * * *2
> > > C3 * * * * *123456 * * * * *3
> > > C4 * * * * *123456 * * * * *4
> > > C10 * * * * 789012 * * * * 1
> > > C45 * * * * 348975 * * * * 1
> > > C150 * * * *789012 * * * * 2
> > > C334 * * * *789012 * * * * 3

>
> > > Thanks in advance for your time and help.

>
> JP,
>
> Thanks! This is getting REALLY, REALLY CLOSE to what I need. It is not
> exactly what I need only b/c because my examples were incomplete. My
> fault entirely.
>
> In many cases, the numbers in column C might start with a letter (v).
> For example:
>
> C1 * * * * *v123456 * * * * *1
> C2 * * * * *v123456 * * * * *2
> C3 * * * * *v123456 * * * * *3
> C4 * * * * *v123456 * * * * *4
> C10 * * * * 789012 * * * * 1
> C45 * * * * 348975 * * * * 1
> C150 * * * *789012 * * * * 2
> C334 * * * *789012 * * * * 3
> C53 * * * *v569802 * * * * 1
> C450 * * *v569802 * * * * 2
>
> Any ideas?- Hide quoted text -
>
> - Show quoted text -


 
Reply With Quote
 
A Newton
Guest
Posts: n/a
 
      15th Jan 2008
On Jan 15, 1:54 pm, feltra <fel...@gmail.com> wrote:
> Hi,
>
> If you havent found the formula to populate cells in col Q based for
> unique values in Col C, here's the formula that will do exactly as
> you want. You can then simply count the 1s in col Q to get the unique
> values in Col C:
>
> In first row of data (say row 1) key in this formula in Col Q:
> =COUNTIF($C$1:$C1,C1)
>
> Highlight all the cells in Col Q from row1 to end of data row (say row
> 450 in your example). Then do a Fill Down (CTRL-D). The important
> thing is to give the absolute and relative references exactly as shown
> (ie. keying in the $ symbol or leaving it out).
>
> The number of unique values in Col C can now be found by
> =COUNTIF($Q$1:$Q$450,1)
> in another results cell in the sheet.
>
> This will work if you do it by hand... For putting in a macro (ie.
> programming) you need a little more work, but can be done...
>
> Hope this helps.
>
> Best Regards,
> -feltra
>
> > Thanks! This is getting REALLY, REALLY CLOSE to what I need. It is not
> > exactly what I need only b/c because my examples were incomplete. My
> > fault entirely.

>
> > In many cases, the numbers in column C might start with a letter (v).
> > For example:

>
> > C1 v123456 1
> > C2 v123456 2
> > C3 v123456 3
> > C4 v123456 4
> > C10 789012 1
> > C45 348975 1
> > C150 789012 2
> > C334 789012 3
> > C53 v569802 1
> > C450 v569802 2

>
> > Any ideas?


Thanks! Great suggestion. That worked like a charm. All items in
column Q are now appropriately numbered.

One follow-up --

On another worksheet -- worksheet 2 -- I now want to tally all the
items that have a value of 1 in column Q and that also have a value of
"foo" in column A and "bar" in column M on worksheet 1. I thought I
could find all the items that I was looking for with this formula:

=SUMPRODUCT(('worksheet 1'!$A$2:$A$450="foo") * ('worksheet 1'!$M$2:$M
$450="bar") * ('worksheet'!$Q$2:$Q$450="1"))

but it is returning "0" whereas I know from looking at worksheet 1
that I should actually be getting a value of "3".

This:

=SUMPRODUCT(('worksheet 1'!$A$2:$A$450="foo") * ('worksheet 1'!$M$2:$M
$450="bar") * ('worksheet'!$Q$2:$Q$450="1"))

returns "6", which counts all instances without factoring in a value
of "1" in column Q.

Ideas?
 
Reply With Quote
 
A Newton
Guest
Posts: n/a
 
      15th Jan 2008
On Jan 15, 3:14 pm, A Newton <adamfnew...@gmail.com> wrote:
> On Jan 15, 1:54 pm, feltra <fel...@gmail.com> wrote:
>
>
>
> > Hi,

>
> > If you havent found the formula to populate cells in col Q based for
> > unique values in Col C, here's the formula that will do exactly as
> > you want. You can then simply count the 1s in col Q to get the unique
> > values in Col C:

>
> > In first row of data (say row 1) key in this formula in Col Q:
> > =COUNTIF($C$1:$C1,C1)

>
> > Highlight all the cells in Col Q from row1 to end of data row (say row
> > 450 in your example). Then do a Fill Down (CTRL-D). The important
> > thing is to give the absolute and relative references exactly as shown
> > (ie. keying in the $ symbol or leaving it out).

>
> > The number of unique values in Col C can now be found by
> > =COUNTIF($Q$1:$Q$450,1)
> > in another results cell in the sheet.

>
> > This will work if you do it by hand... For putting in a macro (ie.
> > programming) you need a little more work, but can be done...

>
> > Hope this helps.

>
> > Best Regards,
> > -feltra

>
> > > Thanks! This is getting REALLY, REALLY CLOSE to what I need. It is not
> > > exactly what I need only b/c because my examples were incomplete. My
> > > fault entirely.

>
> > > In many cases, the numbers in column C might start with a letter (v).
> > > For example:

>
> > > C1 v123456 1
> > > C2 v123456 2
> > > C3 v123456 3
> > > C4 v123456 4
> > > C10 789012 1
> > > C45 348975 1
> > > C150 789012 2
> > > C334 789012 3
> > > C53 v569802 1
> > > C450 v569802 2

>
> > > Any ideas?

>
> Thanks! Great suggestion. That worked like a charm. All items in
> column Q are now appropriately numbered.
>
> One follow-up --
>
> On another worksheet -- worksheet 2 -- I now want to tally all the
> items that have a value of 1 in column Q and that also have a value of
> "foo" in column A and "bar" in column M on worksheet 1. I thought I
> could find all the items that I was looking for with this formula:
>
> =SUMPRODUCT(('worksheet 1'!$A$2:$A$450="foo") * ('worksheet 1'!$M$2:$M
> $450="bar") * ('worksheet'!$Q$2:$Q$450="1"))
>
> but it is returning "0" whereas I know from looking at worksheet 1
> that I should actually be getting a value of "3".
>
> This:
>
> =SUMPRODUCT(('worksheet 1'!$A$2:$A$450="foo") * ('worksheet 1'!$M$2:$M
> $450="bar") * ('worksheet'!$Q$2:$Q$450="1"))
>
> returns "6", which counts all instances without factoring in a value
> of "1" in column Q.
>
> Ideas?


There was a typo in my previous examples. They should be:

=SUMPRODUCT(('worksheet 1'!$A$2:$A$450="foo") * ('worksheet 1'!$M$2:$M
$450="bar") * ('worksheet 1'!$Q$2:$Q$450="1"))

and

=SUMPRODUCT(('worksheet 1'!$A$2:$A$450="foo") * ('worksheet 1'!$M$2:$M
$450="bar") * ('worksheet 1'!$Q$2:$Q$450="1"))
 
Reply With Quote
 
A Newton
Guest
Posts: n/a
 
      15th Jan 2008
On Jan 15, 3:53 pm, A Newton <adamfnew...@gmail.com> wrote:
> On Jan 15, 3:14 pm, A Newton <adamfnew...@gmail.com> wrote:
>
>
>
> > On Jan 15, 1:54 pm, feltra <fel...@gmail.com> wrote:

>
> > > Hi,

>
> > > If you havent found the formula to populate cells in col Q based for
> > > unique values in Col C, here's the formula that will do exactly as
> > > you want. You can then simply count the 1s in col Q to get the unique
> > > values in Col C:

>
> > > In first row of data (say row 1) key in this formula in Col Q:
> > > =COUNTIF($C$1:$C1,C1)

>
> > > Highlight all the cells in Col Q from row1 to end of data row (say row
> > > 450 in your example). Then do a Fill Down (CTRL-D). The important
> > > thing is to give the absolute and relative references exactly as shown
> > > (ie. keying in the $ symbol or leaving it out).

>
> > > The number of unique values in Col C can now be found by
> > > =COUNTIF($Q$1:$Q$450,1)
> > > in another results cell in the sheet.

>
> > > This will work if you do it by hand... For putting in a macro (ie.
> > > programming) you need a little more work, but can be done...

>
> > > Hope this helps.

>
> > > Best Regards,
> > > -feltra

>
> > > > Thanks! This is getting REALLY, REALLY CLOSE to what I need. It is not
> > > > exactly what I need only b/c because my examples were incomplete. My
> > > > fault entirely.

>
> > > > In many cases, the numbers in column C might start with a letter (v).
> > > > For example:

>
> > > > C1 v123456 1
> > > > C2 v123456 2
> > > > C3 v123456 3
> > > > C4 v123456 4
> > > > C10 789012 1
> > > > C45 348975 1
> > > > C150 789012 2
> > > > C334 789012 3
> > > > C53 v569802 1
> > > > C450 v569802 2

>
> > > > Any ideas?

>
> > Thanks! Great suggestion. That worked like a charm. All items in
> > column Q are now appropriately numbered.

>
> > One follow-up --

>
> > On another worksheet -- worksheet 2 -- I now want to tally all the
> > items that have a value of 1 in column Q and that also have a value of
> > "foo" in column A and "bar" in column M on worksheet 1. I thought I
> > could find all the items that I was looking for with this formula:

>
> > =SUMPRODUCT(('worksheet 1'!$A$2:$A$450="foo") * ('worksheet 1'!$M$2:$M
> > $450="bar") * ('worksheet'!$Q$2:$Q$450="1"))

>
> > but it is returning "0" whereas I know from looking at worksheet 1
> > that I should actually be getting a value of "3".

>
> > This:

>
> > =SUMPRODUCT(('worksheet 1'!$A$2:$A$450="foo") * ('worksheet 1'!$M$2:$M
> > $450="bar") * ('worksheet'!$Q$2:$Q$450="1"))

>
> > returns "6", which counts all instances without factoring in a value
> > of "1" in column Q.

>
> > Ideas?

>
> There was a typo in my previous examples. They should be:
>
> =SUMPRODUCT(('worksheet 1'!$A$2:$A$450="foo") * ('worksheet 1'!$M$2:$M
> $450="bar") * ('worksheet 1'!$Q$2:$Q$450="1"))
>
> and
>
> =SUMPRODUCT(('worksheet 1'!$A$2:$A$450="foo") * ('worksheet 1'!$M$2:$M
> $450="bar") * ('worksheet 1'!$Q$2:$Q$450="1"))


Issue solved. . .

I removed the double-quotes from around the "1" like so:

=SUMPRODUCT(('worksheet 1'!$A$2:$A$450="foo") * ('worksheet 1'!$M$2:$M
$450="bar") * ('worksheet 1'!$Q$2:$Q$450=1))
 
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
Count occurrences Lorri Microsoft Access Getting Started 1 22nd Jan 2010 07:15 PM
Count Account Services with multiple occurrences crspycrtr Microsoft Access Queries 1 14th May 2008 12:58 PM
how do I count occurrences of multiple conditions =?Utf-8?B?RGViaQ==?= Microsoft Excel Worksheet Functions 1 5th Oct 2006 05:11 PM
count occurrences =?Utf-8?B?UkhEMw==?= Microsoft Access 1 4th Aug 2006 06:26 PM
how do I count the occurrences of multiple conditions =?Utf-8?B?RGViaQ==?= Microsoft Excel Worksheet Functions 8 18th Jul 2006 02:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:32 PM.