Count by unique criteria in a separate column

cabaragoya

New Member
Joined
Mar 8, 2023
Messages
1
Office Version
  1. 365
Platform
  1. MacOS
  2. Web
I have dataset similar to below. I would like to count Status by unique Product ID.

r/excel - Count by unique criteria in a separate column

Once there is a confirmed status on any version in a Product ID, the Product ID should count as "Confirmed", even if there are other versions that are marked "Not Started" or "Pending". (For example, Product 1000, 1004, and 1006 should count as "Confirmed".)

Similarly, if there is not a "Confirmed" status, but there is a "Pending" status on any version within a Product ID, that product should count as "Pending", even if there are other versions that are "Not Started". (For example, Product 1002 should count as "Pending".)

Ideally, the count would end up looking similar to this table:
r/excel - Count by unique criteria in a separate column

What formulas can I write in the table to count the Confirmed, Pending, and Not Started statuses as described?
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Formula base solution with a helper column
Bảng tính số tháng.xlsx
ABCDEFG
1HelperCount
21000aConfirmedConfirmedConfirmed3
31000bConfirmedConfirmedPending1
41000cNot StartedConfirmedNot Started2
51000dNot StartedConfirmed
61002ePendingPending
71002fNot StartedPending
81002gNot StartedPending
91002hNot StartedPending
101003jNot StartedNot Started
111003iNot StartedNot Started
121003kNot StartedNot Started
131003lNot StartedNot Started
141004mConfirmedConfirmed
151004nConfirmedConfirmed
161004oConfirmedConfirmed
171004pPendingConfirmed
181004qPendingConfirmed
191005rNot StartedNot Started
201005sNot StartedNot Started
211005tNot StartedNot Started
221005uNot StartedNot Started
231006vConfirmedConfirmed
241006wPendingConfirmed
251006xNot StartedConfirmed
261006yNot StartedConfirmed
271006zNot StartedConfirmed
Sheet2
Cell Formulas
RangeFormula
F2F2=C2
G2:G4G2=SUMPRODUCT(IF($D$2:$D$27=$F2,1/COUNTIFS($D$2:$D$27,$F2,$A$2:$A$27,$A$2:$A$27)))
F3:F4F3=C6
D2:D27D2=IF(COUNTIFS($A$2:$A$27,A2,$C$2:$C$27,"Confirmed"),"Confirmed",IF(COUNTIFS($A$2:$A$27,A2,$C$2:$C$27,"Pending"),"Pending","Not Started"))
Press CTRL+SHIFT+ENTER to enter array formulas.


Without helper, would offer an UDF (via VBA) solution. Call me back if you interested in.
 
Upvote 0
Here is a Power Query solution

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}, {"Column2", type text}, {"Column3", type text}}),
    #"Removed Duplicates" = Table.Distinct(#"Changed Type", {"Column1", "Column3"}),
    #"Grouped Rows" = Table.Group(#"Removed Duplicates", {"Column3"}, {{"Count", each Table.RowCount(Table.Distinct(_)), Int64.Type}})
in
    #"Grouped Rows"
 
Upvote 0
Formula solution without helper col

23 03 09.xlsm
ABCDEFG
1Count
21000aConfirmedConfirmed3
31000bConfirmedPending1
41000cNot StartedNot Started2
51000dNot Started
61002ePending
71002fNot Started
81002gNot Started
91002hNot Started
101003jNot Started
111003iNot Started
121003kNot Started
131003lNot Started
141004mConfirmed
151004nConfirmed
161004oConfirmed
171004pPending
181004qPending
191005rNot Started
201005sNot Started
211005tNot Started
221005uNot Started
231006vConfirmed
241006wPending
251006xNot Started
261006yNot Started
271006zNot Started
Count
Cell Formulas
RangeFormula
G2G2=COUNT(UNIQUE(FILTER(A2:A27,C2:C27=F2,"")))
G3G3=COUNT(UNIQUE(FILTER(A2:A27,(C2:C27=F3)*(COUNTIFS(A2:A27,A2:A27,C2:C27,F2)=0),"")))
G4G4=COUNT(UNIQUE(FILTER(A2:A27,(C2:C27=F4)*(COUNTIFS(A2:A27,A2:A27,C2:C27,F2)+COUNTIFS(A2:A27,A2:A27,C2:C27,F3)=0),"")))
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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