问题
I am attempting to exclude values my countif formula has already counted, and instead insert a value such as "Already counted".
I need to count how many times a specific item appears in a column, which I used the basic countif formula for: =COUNTIF(A:A,A2). It returned these results:
Name # of Name
Mike 2
Sally 2
John 3
Kim 2
Jose 2
Sally 2
John 3
Brenda 1
John 3
Jose 2
Kim 2
Mike 2
(Column A is the "Name", Column B is the formula column "# of Name".)
OK, great. The issue is when the second occurrence of "Sally" happens, it counts the word again. I would like to ignore it because it has already been counted, and instead insert another value, such as "Already Counted". Thank you for your help in advance.
回答1:
Use MATCH to test if first in the list:
=IF(MATCH(A2,A:A,0)=ROW(),COUNTIF(A:A,A2),"Already Counted")
回答2:
You can COUNTIF
for the limited range ending with the current row, and, if more than 1
, you know it was already counted
=IF(COUNTIF($A$2:A2,A2)=1,COUNTIF($A:$A,A2),"Already Counted")
EDIT: Having just seen it, I like Scott's solution also.
来源:https://stackoverflow.com/questions/46160451/how-to-ignore-data-previously-counted-by-countif-and-return-a-specific-value-in