Count Duplicate Rows with Conditions

wolf11

New Member
Joined
Jul 9, 2012
Messages
2
Hi, Anyone who can help me with a formula for counting unique rows with condition

1) it must count only the unique task number
2) the counted unique task number must have task type P
result: 3


( optional ) Count Unique Task Number must have Task Type P with Name D
result: 1


I know the formula to compute for unique text only in one row but what bout with conditions?
Would really appreciate help :)

=SUMPRODUCT((B3:B12<>"")/COUNTIF(B3:B12,B3:B12&""))


[TABLE="width: 329"]
<tbody>[TR]
[TD][TABLE="class: outer_border, width: 500, align: left"]
<tbody>[TR]
[TD]A1[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Task Number[/TD]
[TD]Task Type[/TD]
[TD]Name[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]T1[/TD]
[TD]C[/TD]
[TD]M[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]T2[/TD]
[TD]P[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]T2[/TD]
[TD]P[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]T3[/TD]
[TD]C[/TD]
[TD]M[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]T4[/TD]
[TD]C[/TD]
[TD]L[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]T5[/TD]
[TD]C[/TD]
[TD]M[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]T6[/TD]
[TD]P[/TD]
[TD]R[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]T6[/TD]
[TD]P[/TD]
[TD]R[/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD]T7[/TD]
[TD]P[/TD]
[TD]R[/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]T8[/TD]
[TD]C[/TD]
[TD]L[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Excel 2010
ABCDE
1Task NumberTask TypeName
2T1CM31
3T2PD
4T2PD
5T3CM
6T4CL
7T5CM
8T6PR
9T6PR
10T7PR
11T8CL
Sheet2
Cell Formulas
RangeFormula
D2{=SUM(IF(FREQUENCY(IF(B2:B11="P",MATCH("~"&A2:A11,A2:A11&"",0)),ROW(A2:A11)-ROW(A2)+1),1))}
E2{=SUM(IF(FREQUENCY(IF(B2:B11="P",IF($C$2:$C$11="D",MATCH("~"&A2:A11,A2:A11&"",0))),ROW(A2:A11)-ROW(A2)+1),1))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Hi, Anyone who can help me with a formula for counting unique rows with condition

1) it must count only the unique task number
2) the counted unique task number must have task type P
result: 3


( optional ) Count Unique Task Number must have Task Type P with Name D
result: 1


I know the formula to compute for unique text only in one row but what bout with conditions?
Would really appreciate help :)

=SUMPRODUCT((B3:B12<>"")/COUNTIF(B3:B12,B3:B12&""))


[TABLE="width: 329"]
<tbody>[TR]
[TD]
[TABLE="class: outer_border, width: 500, align: left"]
<tbody>[TR]
[TD]A1
[/TD]
[TD]B
[/TD]
[TD]C
[/TD]
[TD]D
[/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]Task Number
[/TD]
[TD]Task Type
[/TD]
[TD]Name
[/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]T1
[/TD]
[TD]C
[/TD]
[TD]M
[/TD]
[/TR]
[TR]
[TD]4
[/TD]
[TD]T2
[/TD]
[TD]P
[/TD]
[TD]D
[/TD]
[/TR]
[TR]
[TD]5
[/TD]
[TD]T2
[/TD]
[TD]P
[/TD]
[TD]D
[/TD]
[/TR]
[TR]
[TD]6
[/TD]
[TD]T3
[/TD]
[TD]C
[/TD]
[TD]M
[/TD]
[/TR]
[TR]
[TD]7
[/TD]
[TD]T4
[/TD]
[TD]C
[/TD]
[TD]L
[/TD]
[/TR]
[TR]
[TD]8
[/TD]
[TD]T5
[/TD]
[TD]C
[/TD]
[TD]M
[/TD]
[/TR]
[TR]
[TD]9
[/TD]
[TD]T6
[/TD]
[TD]P
[/TD]
[TD]R
[/TD]
[/TR]
[TR]
[TD]10
[/TD]
[TD]T6
[/TD]
[TD]P
[/TD]
[TD]R
[/TD]
[/TR]
[TR]
[TD]11
[/TD]
[TD]T7
[/TD]
[TD]P
[/TD]
[TD]R
[/TD]
[/TR]
[TR]
[TD]12
[/TD]
[TD]T8
[/TD]
[TD]C
[/TD]
[TD]L
[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Control+shift+enter, not just enter...

1)
Rich (BB code):
=SUM(IF(FREQUENCY(IF(B3:B12<>"",MATCH("~"&B3:B12,B3:B12&"",0)),
  ROW(B3:B12)-ROW(B3)+1),1))
2)
Rich (BB code):
=SUM(IF(FREQUENCY(IF(B3:B12<>"",IF(C3:C12="P",
  MATCH("~"&B3:B12,B3:B12&"",0))),ROW(B3:B12)-ROW(B3)+1),1))
3)
Rich (BB code):
=SUM(IF(FREQUENCY(IF(B3:B12<>"",IF(C3:C12="P",IF(D3:D12="D",
  MATCH("~"&B3:B12,B3:B12&"",0)))),ROW(B3:B12)-ROW(B3)+1),1))

if there are no special meaning chars around the entries in column B, you might want to remove the "~"& and &"" bits from the formulas.
 
Upvote 0
Hi,
You can use the following code:
Code:
Sub Counting()
Dim i&, NoDupes As New Collection

On Error Resume Next
For i = 3 To 12
  If Cells(i, 3).Value = "P" Then 'And Cells(i, 4).Value = "D"
    NoDupes.Add 1, Cells(i, 2).Value
  End If
Next i

MsgBox NoDupes.Count
End Sub
Best regards.
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

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