【问题标题】:Formula for Counting recurring "Pairs"计算重复“对”的公式
【发布时间】:2019-07-05 09:37:18
【问题描述】:

在下面的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,我确信它是解决方案的关键,但我不确定配对版本是什么样的

【问题讨论】:

  • 请决定您要使用 Google 表格还是 Excel。两个应用程序之间存在很多差异,解决方案可能不适用于两者
  • 对不起,我没有意识到他们没有等效的解决方案,删除了 excel 参考

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


【解决方案1】:

没有第三列:

=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)


全表:

=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))

【讨论】:

  • QUERY是个了不起的功能,我怎么不知道呢!道具!谢谢!
【解决方案2】:

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

=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     |

然后你可以从第 3 列中计算最常见的值,当我 googled 时,它看起来像这样

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

【讨论】:

  • 你可以使用=INDEX(C14:C29,MODE(MATCH(C14:C29,C14:C29)))
  • 谢谢,这行得通,但是如果它有空单元格,它似乎会很困难,知道为什么吗?我在电子表格中将其弹出为“alt 将变为 29”
猜你喜欢
  • 2013-02-06
  • 1970-01-01
  • 1970-01-01
  • 2017-07-24
  • 1970-01-01
  • 2021-05-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多