#1   Report Post  
Posted to microsoft.public.excel.misc
John Moore
 
Posts: n/a
Default Count Distinct only

Hi Guys, Problem I am trying to resolve is this, I am trying to extract data
from a table of data, I want the result to tell me the number of times a
certain piece of info appears ,,, example table
Product Code Cost
1 Pen 12345 £2:50
2 Pencil 13456 £1:00
3 Pen 12345 £2:50
4 Pen 12378 £2:50
5 Pen 12378 £2:50

Normmaly I would extract the number of times Pen appears by doing a simple
Countif on column A, however, I would like to extract the number of Codes
that appear in column B when Pen appears in column A, in the example above
the reult would be 4 fo column A, any ideas?
  #2   Report Post  
Posted to microsoft.public.excel.misc
Roger Govier
 
Posts: n/a
Default Count Distinct only

Hi John

In your example every occurrence of Pen has a code so a Countif of Pen would
yield the same result.
If there is not always a code then
=SUMPRODUCT(--(A1:A5="Pen"),--(B1:B5<""))
would yield an answer of 4, but a lower value in any codes were blank.

Regards

Roger Govier


John Moore wrote:
Hi Guys, Problem I am trying to resolve is this, I am trying to extract data
from a table of data, I want the result to tell me the number of times a
certain piece of info appears ,,, example table
Product Code Cost
1 Pen 12345 £2:50
2 Pencil 13456 £1:00
3 Pen 12345 £2:50
4 Pen 12378 £2:50
5 Pen 12378 £2:50

Normmaly I would extract the number of times Pen appears by doing a simple
Countif on column A, however, I would like to extract the number of Codes
that appear in column B when Pen appears in column A, in the example above
the reult would be 4 fo column A, any ideas?

  #3   Report Post  
Posted to microsoft.public.excel.misc
John Moore
 
Posts: n/a
Default Count Distinct only

Hi Roger, this wroks to a certain degree, however, is there a way to only
count the number of codes, excluding duplicates, i.e., if a code appears more
than once, only count it once?

"Roger Govier" wrote:

Hi John

In your example every occurrence of Pen has a code so a Countif of Pen would
yield the same result.
If there is not always a code then
=SUMPRODUCT(--(A1:A5="Pen"),--(B1:B5<""))
would yield an answer of 4, but a lower value in any codes were blank.

Regards

Roger Govier


John Moore wrote:
Hi Guys, Problem I am trying to resolve is this, I am trying to extract data
from a table of data, I want the result to tell me the number of times a
certain piece of info appears ,,, example table
Product Code Cost
1 Pen 12345 £2:50
2 Pencil 13456 £1:00
3 Pen 12345 £2:50
4 Pen 12378 £2:50
5 Pen 12378 £2:50

Normmaly I would extract the number of times Pen appears by doing a simple
Countif on column A, however, I would like to extract the number of Codes
that appear in column B when Pen appears in column A, in the example above
the reult would be 4 fo column A, any ideas?


  #4   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default Count Distinct only

John,

Try

=SUM(--(FREQUENCY(IF(A2:A100="Pen",MATCH(B2:B100,B2:B100, 0)),ROW(INDIRECT("1
:"&ROWS(B2:B100))))0))

which is an array formula, so commit with Ctrl-Shift-Enter

--

HTH

RP
(remove nothere from the email address if mailing direct)


"John Moore" wrote in message
...
Hi Roger, this wroks to a certain degree, however, is there a way to only
count the number of codes, excluding duplicates, i.e., if a code appears

more
than once, only count it once?

"Roger Govier" wrote:

Hi John

In your example every occurrence of Pen has a code so a Countif of Pen

would
yield the same result.
If there is not always a code then
=SUMPRODUCT(--(A1:A5="Pen"),--(B1:B5<""))
would yield an answer of 4, but a lower value in any codes were blank.

Regards

Roger Govier


John Moore wrote:
Hi Guys, Problem I am trying to resolve is this, I am trying to

extract data
from a table of data, I want the result to tell me the number of times

a
certain piece of info appears ,,, example table
Product Code Cost
1 Pen 12345 £2:50
2 Pencil 13456 £1:00
3 Pen 12345 £2:50
4 Pen 12378 £2:50
5 Pen 12378 £2:50

Normmaly I would extract the number of times Pen appears by doing a

simple
Countif on column A, however, I would like to extract the number of

Codes
that appear in column B when Pen appears in column A, in the example

above
the reult would be 4 fo column A, any ideas?




  #5   Report Post  
Posted to microsoft.public.excel.misc
Gary''s Student
 
Posts: n/a
Default Count Distinct only

Consider creating a helper column formed by concatinating Product and Code.

=A1 & B1

This would reduce your problem back to one dimension and you could still use
you countif technique.
--
Gary's Student


"John Moore" wrote:

Hi Guys, Problem I am trying to resolve is this, I am trying to extract data
from a table of data, I want the result to tell me the number of times a
certain piece of info appears ,,, example table
Product Code Cost
1 Pen 12345 £2:50
2 Pencil 13456 £1:00
3 Pen 12345 £2:50
4 Pen 12378 £2:50
5 Pen 12378 £2:50

Normmaly I would extract the number of times Pen appears by doing a simple
Countif on column A, however, I would like to extract the number of Codes
that appear in column B when Pen appears in column A, in the example above
the reult would be 4 fo column A, any ideas?

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
Count Distinct Values? bill_morgan Excel Worksheet Functions 7 April 27th 05 02:12 AM
count distinct in Pivot table soe Excel Discussion (Misc queries) 1 February 22nd 05 01:13 PM
Count Distinct Values by Group Using Pivot Table (NM) MCP Excel Worksheet Functions 3 February 11th 05 09:22 PM
how can I count distinct names in an excel list? RPC@Frito Excel Discussion (Misc queries) 5 February 3rd 05 09:12 PM
Count distinct Debbie t Excel Worksheet Functions 2 November 3rd 04 08:42 PM


All times are GMT +1. The time now is 04:54 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"