【问题标题】:Group By ID and COUNT By SUB UNIQUE ID in Google Sheet or Excel在 Google Sheet 或 Excel 中按 ID 分组和按 SUB UNIQUE ID 计数
【发布时间】:2023-03-15 08:50:01
【问题描述】:

我在 Google 表格中有这些数据(很可能与 Excel 中的原理相同)

ID     SUB ID    COUNT Unique Sub-ID

1       1A         2
1       1A         2 
1       1B         2
2       2A         1
3       3A         3
3       3B         3
3       3B         3
3       3D         3

所以举例来说,ID 1 有 1A 和 1B,两个唯一的子 ID。如何在 Google 表格中以这种方式计算?

【问题讨论】:

  • 您的公式在技术上适用于 Google 表格,但它返回 0。您到底想做什么?计算 A 列和 B 列的所有唯一组合?
  • 不,它不起作用。我想知道 EX:Group ID 1 的 UNIQUE SUB ID 的数量
  • 我不能做数据透视表,因为我有很多 ID。
  • 你不能直接用=COUNTA(UNIQUE(FILTER(B:B,A:A=A2)))
  • =COUNTUNIQUE(query(A1:B, "select B where A = 1"))

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


【解决方案1】:

如果你想使用数组公式,你可以试试这个:

=ArrayFormula({unique(filter(A2:A,A2:A<>"")),countif(index(unique(A2:B),0,1),unique(filter(A2:A,A2:A<>"")))})

【讨论】:

    【解决方案2】:

    使用:

    =ARRAYFORMULA(IFNA(VLOOKUP(A1:A, QUERY(UNIQUE(A1:B), 
     "select Col1,count(Col2) where Col1 is not null group by Col1"), 2, 0)))
    

    【讨论】:

      猜你喜欢
      • 2015-06-01
      • 2012-11-02
      • 2018-04-10
      • 1970-01-01
      • 2017-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-28
      相关资源
      最近更新 更多