介绍用于搜索简化多个COUNTIFS:在Excel 2010
我有我使用的追踪游戏炉石统计Excel工作簿。一张表包含每个单独游戏的数据(赢取损失等)。另一张表格允许用户根据用户输入的搜索标准搜索赢/输统计。
我的问题:
在搜索片我使用COUNTIFS公式。这些公式变得相当长。有什么办法可以简化COUNTIFS公式吗?
的设置:Excel的搜索页的外观:
| Column K | Column L |
|____________________|______________________________|
Row 5 |Date Start | User input goes in Column L |
Row 6 |Date End | |
Row 7 |Player's Class | |
... |Turn Number | |
|Deck Name | |
|Opponent's Class | |
|Opponent's Username | |
|Match Type 1 | |
|Match Type 2 | |
|Match Type 3 | |
|Match Type 4 | |
... |Match Type 5 | |
Row 17 |Match Type 6 | |
|____________________|______________________________|
| Column K | Column L |
|______________________|_______________________________________________|
Row 21 | Total Matches Played | Data is displayed based on the user's input. |
Row 22 | Total Wins | The code that needs simplifying is goes here. |
Row 23 | Total Losses | |
Row 24 | Win to Loss Ratio | |
Row 25 | Win Percentage | |
Row 26 | Loss Percentage | |
|______________________|_______________________________________________|
需要简化了代码。这一代码进入在行22L栏:
=(COUNTIFS('Indiv. Match Stats'!I:I,"Win",'Indiv. Match Stats'!H:H,L12,
'Indiv. Match Stats'!L:L,L7,'Indiv. Match Stats'!T:T,L9,'Indiv. Match
Stats'!Q:Q,L10,'Indiv. Match Stats'!P:P,L11,'Indiv. Match Stats'!C:C,
">="&L5,'Indiv. Match Stats'!C:C,"<="&L6,'Indiv. Match Stats'!N:N,L8))
+
(COUNTIFS('Indiv. Match Stats'!I:I,"Win",'Indiv. Match Stats'!H:H,L13,
'Indiv. Match Stats'!L:L,L7,'Indiv. Match Stats'!T:T,L9,'Indiv. Match
Stats'!Q:Q,L10,'Indiv. Match Stats'!P:P,L11,'Indiv. Match Stats'!C:C,
">="&L5,'Indiv. Match Stats'!C:C,"<="&L6,'Indiv. Match Stats'!N:N,L8))
+
(The code repeats the above four more times. Basically each block of code
stands for one Match Type in Column K)
工作表的说明和代码:通过按行5
用户输入标准17,列L.任何空白处理为通配符。用户输入标准缩小了搜索结果并确定了列21中的行21至26中显示的数据。
上面显示的代码多次引用名为Indiv. Match Stats
的单独图纸。 COUNTIFS按日期,玩家类别,转数,牌组名称,...和比赛类型缩小搜索范围。不幸的是,所有这些标准都必须重复,每种匹配类型一次,然后代码添加结果,给出最终结果(给定标准的适当数量的胜利,损失等)。它是一大块代码,被添加到另一个代码块中。
有没有更好的方法来做到这一点或只是以某种方式在视觉上简单的代码?有没有办法让类似的代码块等于一些变量,以便那些类似的部分不必被重复输入?
感谢您使用此解决方案。我也将COUNTFS作为数组公式进行测试。但我没有考虑过,某些Excel函数本身不是作为数组公式运行,而是在数组的上下文中以数组的形式获取它们的参数。 – 2014-08-29 04:28:40
谢谢!如果您为匹配类型放入两次相同的搜索字词,我知道该公式会进行双重计数。我认为停止重复计算会是一个全新的问题,而且是一个非常修改或不同的公式? – user2348797 2014-08-29 05:11:47
为避免重复计算,我认为您需要SUMPRODUCT按照Axel的建议,但对于“OR”部分,您可以使用MATCH,即“ISNUMBER(MATCH('Indiv。Match Stats'!H:H,L12:L17,0 )) - 这样你就可以扩展L12:L17的大小,而不需要扩大公式......正如Axel所说,使用SUMPRODUCT,最好使用特定范围而不是整列,否则公式会变慢 – 2014-08-29 12:31:20