Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 90
Default Counting unique values with criteria

I need to count the number of unique cases given certain criteria. For
example,

Case # Code
3356 Stroke
3356 Stroke
3357 Cancer
3357 Cancer
3356 Cancer
The results should indicate: 1 unique case for Stroke; 2 unique cases for
Cancer. Thanks for any help.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,572
Default Counting unique values with criteria

Enter the "Code" criteria in C1, then try this *array* formula:

=COUNT(1/FREQUENCY(IF((B2:B6=C1),MATCH(A2:A6,A2:A6,0)),ROW( 1:5)))

--
Array formulas must be entered with CSE, <Ctrl <Shift <Enter, instead of
the regular <Enter, which will *automatically* enclose the formula in curly
brackets, which *cannot* be done manually. Also, you must use CSE when
revising the formula.


--
HTH,

RD

---------------------------------------------------------------------------
Please keep all correspondence within the NewsGroup, so all may benefit !
---------------------------------------------------------------------------

"Chuck" wrote in message
...
I need to count the number of unique cases given certain criteria. For
example,

Case # Code
3356 Stroke
3356 Stroke
3357 Cancer
3357 Cancer
3356 Cancer
The results should indicate: 1 unique case for Stroke; 2 unique cases for
Cancer. Thanks for any help.



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default Counting unique values with criteria

I would be inclined to do that with a pivot table. Check out this link on
counting unique in a pivot.

http://www.contextures.com/xlPivot07.html#Unique

here is how you do it...
In column C add this formula
=IF(SUMPRODUCT(($A$2:$A2=A2)*($B$2:$B2=B2))1,0,1)
and copy down. Add a heading called Unique.

Now create a pivot table off of that data. Add the Case to the left column
and Unique to the data section...

You could also just do a sumif formula at this point...
=SUMIF(B2:B6, "=Cancer", C2:C6)
--
HTH...

Jim Thomlinson


"Chuck" wrote:

I need to count the number of unique cases given certain criteria. For
example,

Case # Code
3356 Stroke
3356 Stroke
3357 Cancer
3357 Cancer
3356 Cancer
The results should indicate: 1 unique case for Stroke; 2 unique cases for
Cancer. Thanks for any help.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15,768
Default Counting unique values with criteria

Try this...

Data in the range A2:B6. Assumes no empty cells in the "Case" range.

D2:D3 = stroke, cancer

Enter this array formula** in E2 and copy down as needed:

=SUM(IF(FREQUENCY(IF(B$2:B$6=D2,A$2:A$6),A$2:A$6), 1))

** array formulas need to be entered using the key combination of
CTRL,SHIFT,ENTER (not just ENTER). Hold down both the CTRL key and the SHIFT
key then hit ENTER.

--
Biff
Microsoft Excel MVP


"Chuck" wrote in message
...
I need to count the number of unique cases given certain criteria. For
example,

Case # Code
3356 Stroke
3356 Stroke
3357 Cancer
3357 Cancer
3356 Cancer
The results should indicate: 1 unique case for Stroke; 2 unique cases for
Cancer. Thanks for any help.



  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 90
Default Counting unique values with criteria

Thank you. That was helpful.

"Chuck" wrote:

I need to count the number of unique cases given certain criteria. For
example,

Case # Code
3356 Stroke
3356 Stroke
3357 Cancer
3357 Cancer
3356 Cancer
The results should indicate: 1 unique case for Stroke; 2 unique cases for
Cancer. Thanks for any help.

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 entries with criteria Rachel Excel Discussion (Misc queries) 10 January 15th 10 04:35 PM
Counting unique values with criteria Kevin McCartney Excel Worksheet Functions 10 December 31st 09 04:02 PM
Unique Counting With Multiple Criteria Morton Detwyler[_2_] Excel Worksheet Functions 9 March 16th 09 08:12 AM
Counting Unique Values with Multiple Criteria Amber Excel Worksheet Functions 3 September 25th 07 02:52 PM
Counting Unique Values Given Criteria carl Excel Worksheet Functions 2 August 20th 05 04:22 PM


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