devcoder112
devcoder112

Reputation: 161

ID, count where Y by ID

I am trying to produce the below column ID_Error_Flag_Y_Count. Please see below data have and data want. Please see my attempt below.

I want to count how many times Error_Flag = Y by ID.

My Attempt: Create a pivot table by ID and where Error Flag = Y. Then VLOOKUP by ID and add the ID_Error_Flag_Y_Count to the original file. THis method works but I want to know if there is an easier way.

Data Have   
ID  Error Flag
1   Y
2   Y
3   N
3   Y
3   Y

This is what I want

Data Want       
ID  Error Flag  ID_Error_Flag_Y_Count
1   Y   1
2   Y   1
3   N   2
3   Y   2
3   Y   2

Upvotes: 0

Views: 36

Answers (1)

BigBen
BigBen

Reputation: 49998

Use COUNTIFS:

 =COUNTIFS($A$2:$A$6,A2,$B$2:$B$6,"Y")

enter image description here

Upvotes: 2

Related Questions