Excel - Search through a column to find if text matches and count string

霸气de小男生 提交于 2020-01-04 15:28:56

问题


I want to add values from 1 worksheet to another.

The first worksheet ("November 2011") simply contains name & status, names are however duplicated and a percentage of a string needs to be added on the second worksheet ("Sales").

e.g. "November 2011"

    A           B
1   Name        Status
2   McDonalds   Completed
3   McDonalds   Won
4   Burger King Won
5   Burger King Won
6   Wendys      Completed
7   iHop        Completed
8   iHop        Completed

The second worksheet ("Sales") contains 3 columns Name, Completed & Won. However, Name has had duplicates removed.

e.g. "Sales"

    A           B           C
1   Name        Completed   Won
2   McDonalds   
3   Burger King 
4   Wendys      
5   iHop    

I want the "Sales" worksheet to look like this however:

    A           B           C
1   Name        Completed   Won
2   McDonalds   50%         50%
3   Burger King 0%          100%
4   Wendys      100%        0%
5   iHop        100%        0%

Just wondering what formula to use? It needs to check against the name.


回答1:


I'd use a countif function to find the number of sales and countifs to find the number of wins and completed.

=COUNTIFS('November 2011'!$A:$A, A2, 'November 2011'!$B:$B, "won") 
  / COUNTIF('November 2011'!$A:$A,A2)

This would give you the ratio or percent if formatted of the won.




回答2:


Another alternative is to use an "array formula" with AVERAGE function, i.e. this formula in B2

=AVERAGE(IF(November 2011'!$A$2:$A$1000=$A2,IF('November 2011'!$B$2:$B$1000=B$1,1,0)))

confirmed with CTRL+SHIFT+ENTER and copied across and down



来源:https://stackoverflow.com/questions/14423565/excel-search-through-a-column-to-find-if-text-matches-and-count-string

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