How to ignore data previously counted by countif and return a specific value in cell

我的未来我决定 提交于 2019-12-24 12:19:15

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!