Unique Count with Multiple criteria

kiwiorn

New Member
Joined
Jul 30, 2007
Messages
5
I am trying to count the number of cells that meet certain numerous criteria, using excel 2003.

For example, each job has a specific ref number and within that job ref number there is a number of lines of data, some of which we ignore and some of which we include. Each job will have a planning time using an old methodology (Planning A), a planning time using a new methodology (Planning B) and an actual time. There are a few other variables too such as the category of work.

I am trying to count the number of each unique ref no. within the sub category of work I am looking at (there are circa 50 sub categories of work). Each ref no. will only have 1 combination of work cat and sub category.

For example:

Ref# Cat Sub Rel PlanA PlanA Act
X001 A10 1000 Y 1.50 2.50 2.25
X001 A10 1000 Y 1.50 2.50 2.25
X001 A10 1000 N 0.00 0.00 0.00
X002 A10 2000 Y 2.00 1.50 1.70
X002 A10 2000 Y 2.00 1.50 1.70
X003 B10 1050 Y 3.00 3.50 6.90
X003 B10 1050 Y 3.00 3.50 6.90
X004 A10 1000 Y 2.00 1.50 4.00
X004 A10 1000 N 0.00 0.00 0.00
X005 C10 3000 N 0.00 0.00 0.00

I need to do a unique count for each individual work sub category where there is some relevant work done for each job (ref no.).

Cat Sub Count (if relevant)
A10 1000 2
A10 2000 1
B10 1050 1
C10 3000 0

Above there are only 4 relevant jobs in total. What is the count formula I use to achieve the unique count by subcategory above?

Regards
Richard
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
How about something like this??
Excel Workbook
ABCDEFG
1Ref#CatSubRelPlanAPlanAAct
2X001A101000Y1.52.52.25
3X001A101000Y1.52.52.25
4X001A101000N000
5X002A102000Y21.51.7
6X002A102000Y21.51.7
7X003B101050Y33.56.9
8X003B101050Y33.56.9
9X004A101000Y21.54
10X004A101000N000
11X005C103000N000
15X001A102
Sheet1
Cell Formulas
RangeFormula
C15=SUMPRODUCT(--($A$2:$A$11=A15),--($B$2:$B$11=B15),--($D$2:$D$11="Y"))
<input id="gwProxy" type="hidden"><!--Session data--><input *******="jsCall();" id="jsProxy" type="hidden">
 
Upvote 0
Thanks Sandeep. Problem is that I'm not concerned about a count for X001, only the total number of unique references that occur for all cat / sub cat A/1000 for instance. In this case it is 2, being:
X001 and X004

ie. Under the category combination of A 1000 there are 2 unique references that have one or more relevant (Y) lines.

A10/1000 = 2 (X001 and X004)
A10/2000 = 1 (X002)
B10/1050 = 1 (X003)
C10/3000 = 0 (X005 has no line that is relevant)

I think it requires a combination of several formulas using an array but I'm just not sure exactly how to get the unique aspect of the references into the formula.
 
Upvote 0
Hello,

This should work.... used this for help.
Excel Workbook
ABCDEFG
1Ref#CatSubRelPlanAPlanAAct
2X001A101000Y1.52.52.25
3X001A101000Y1.52.52.25
4X001A101000N000
5X002A102000Y21.51.7
6X002A102000Y21.51.7
7X003B101050Y33.56.9
8X003B101050Y33.56.9
9X004A101000Y21.54
10X004A101000N000
11X005C103000N000
12
13A1010002
Sheet1
#VALUE!
<input id="gwProxy" type="hidden"><!--Session data--><input *******="jsCall();" id="jsProxy" type="hidden">
 
Upvote 0
For all the 4 conditions that you mentioned...
Excel Workbook
ABCDEFG
1Ref#CatSubRelPlanAPlanAAct
2X001A101000Y1.52.52.25
3X001A101000Y1.52.52.25
4X001A101000N000
5X002A102000Y21.51.7
6X002A102000Y21.51.7
7X003B101050Y33.56.9
8X003B101050Y33.56.9
9X004A101000Y21.54
10X004A101000N000
11X005C103000N000
12
13A1010002
14A1020001
15B1010501
16C1030000
Sheet1
#VALUE!
<input id="gwProxy" type="hidden"><!--Session data--><input *******="jsCall();" id="jsProxy" type="hidden">
 
Upvote 0
Thanks again Sandeep. This one does the trick nicely. I did have a couple of extra criteria to add in, and am curious, however, how this could be done if I had exceeded the number of nested "if" statements that are allowed (one more than I needed). Any ideas?!!!
 
Upvote 0
Thanks again Sandeep. This one does the trick nicely. I did have a couple of extra criteria to add in, and am curious, however, how this could be done if I had exceeded the number of nested "if" statements that are allowed (one more than I needed). Any ideas?!!!

You can coalesce some of the IFs into a vector multiplication...

Rich (BB code):
=SUM(IF(FREQUENCY(
    IF(($B$2:$B$11=A13)*($C$2:$C$11=B13)*($D$2:$D$11="Y"),
    IF($A$2:$A$11<>"",MATCH($A$2:$A$11,$A$2:$A$11,0))))),
      ROW($A$2:$A$11)-ROW($A$2)+1),1))

Rich (BB code):
=SUM(IF(FREQUENCY(
    IF(($B$2:$B$11=A13)*($C$2:$C$11=B13)*($D$2:$D$11="Y"),
    IF($A$2:$A$11<>"",MATCH("~"&$A$2:$A$11,$A$2:$A$11&"",0))))),
      ROW($A$2:$A$11)-ROW($A$2)+1),1))
 
Upvote 0
You can coalesce some of the IFs into a vector multiplication...


=SUM(IF(FREQUENCY(
IF(($B$2:$B$11=A13)*($C$2:$C$11=B13)*($D$2:$D$11="Y"),
IF($A$2:$A$11<>"",MATCH("~"&$A$2:$A$11,$A$2:$A$11&"",0))))),
ROW($A$2:$A$11)-ROW($A$2)+1),1))
[/code]


Hi Aladin,

In the equation MATCH("~"&$A$2:$A$11,$A$2:$A$11&"",0), what advantage does using "~" have over the regular function?

On going through the formula using Evaluate formula, I didnt find any difference in the way the formula progresses.
 
Upvote 0
Hi Aladin,

In the equation MATCH("~"&$A$2:$A$11,$A$2:$A$11&"",0), what advantage does using "~" have over the regular function?

On going through the formula using Evaluate formula, I didnt find any difference in the way the formula progresses.

You need to find the threads in which the formula is developed. Anyway, they help escape the special meaning of chars like < that might appear in the items of interest.
 
Upvote 0
You can coalesce some of the IFs into a vector multiplication...

Rich (BB code):
=SUM(IF(FREQUENCY(
    IF(($B$2:$B$11=A13)*($C$2:$C$11=B13)*($D$2:$D$11="Y"),
    IF($A$2:$A$11<>"",MATCH($A$2:$A$11,$A$2:$A$11,0))))),
      ROW($A$2:$A$11)-ROW($A$2)+1),1))

Rich (BB code):
=SUM(IF(FREQUENCY(
    IF(($B$2:$B$11=A13)*($C$2:$C$11=B13)*($D$2:$D$11="Y"),
    IF($A$2:$A$11<>"",MATCH("~"&$A$2:$A$11,$A$2:$A$11&"",0))))),
      ROW($A$2:$A$11)-ROW($A$2)+1),1))

Corrected for parens...
Rich (BB code):
=SUM(IF(FREQUENCY(
    IF(($B$2:$B$11=A13)*($C$2:$C$11=B13)*($D$2:$D$11="Y"),
    IF($A$2:$A$11<>"",MATCH("~"&$A$2:$A$11,$A$2:$A$11&"",0))),
      ROW($A$2:$A$11)-ROW($A$2)+1),1))
 
Upvote 0

Forum statistics

Threads
1,223,912
Messages
6,175,340
Members
452,638
Latest member
Oluwabukunmi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top