计算重复“对”的公式

时间:2019-07-05 09:37:18

标签: google-sheets google-sheets-formula array-formulas google-sheets-query google-query-language

在接下来的example中,评估“ 最佳团队”又是不断重复的“ ”对的最佳方法是什么?

| Winner In Event A     | Winner In Event B     |
|-------------------    |-------------------    |
| Bob                   | Alfred                |
| Bob                   | Dave                  |
| Bob                   | Alfred                |
| Jason                 | Alfred                |
| John                  | Fred                  |
| Fred                  | John                  |
| John                  | Fred                  |
| Richard               | Jason                 |
| Richard               | Bob                   |

在这种情况下,我希望它选择 Fred&John ,因为它们配对了3次,而不与仅配对2次的Bob&Alfred捆绑在一起。

在上面的示例中,我包括标准的VLookup,我确定它是解决方案的关键,但是我不确定配对的版本是什么

2 个答案:

答案 0 :(得分:2)

没有第三列:

=INDEX(ARRAYFORMULA(QUERY(IF(LEN(A1:A&B1:B), 
 IF(A1:A>B1:B, A1:A&" & "&B1:B, B1:B&" & "&A1:A), ), 
 "select Col1,count(Col1) group by Col1 order by count(Col1) desc", 0)), 2, 1)

0


完整表格:

=ARRAYFORMULA(QUERY(IF(LEN(A1:A&B1:B), 
 IF(A1:A>B1:B, A1:A&" & "&B1:B, B1:B&" & "&A1:A), ), 
 "select Col1,count(Col1) 
  where Col1 is not null
  group by Col1 
  order by count(Col1) desc
  label count(Col1)''", 0))

0

答案 1 :(得分:0)

我想出了这一点并将其放在上面的示例中,本质上创建了具有这种类型的值的第三列

=IF(A14>B14, A14&" & "&B14, B14&" & "&A14)

哪个会给你类似的东西

| Winner In Event A     | Winner In Event B     | Ordered Team      |
|-------------------    |-------------------    |-----------------  |
| Bob                   | Alfred                | Bob & Alfred      |
| Bob                   | Dave                  | Dave & Bob        |
| Bob                   | Alfred                | Bob & Alfred      |
| Jason                 | Alfred                | Jason & Alfred    |
| John                  | Fred                  | John & Fred       |
| Fred                  | John                  | John & Fred       |
| John                  | Fred                  | John & Fred       |
| Richard               | Jason                 | Richard & Jason   |
| Richard               | Bob                   | Richard & Bob     |

然后,您可以从第三列中算出最常见的值,当我googled时,看起来像这样

=ARRAYFORMULA(INDEX(C14:C29,MATCH(MAX(COUNTIF(C14:C29,C14:C29)),COUNTIF(C14:C29,C14:C29),0)))