【问题标题】:How to count by unique id values that contain specific text in GoogleSpreadsheet如何按包含 Google 电子表格中特定文本的唯一 ID 值进行计数
【发布时间】:2021-02-22 19:13:51
【问题描述】:

对于这个问题,我知道可以通过=query("some code")使用SQL,这种方式完全有效,但如果有更简单的方式更好。

我想在 Google 电子表格中统计所有禁用的帐户,但每个 account_id 只计算一次

account_status  account_id
disabled: 22/02/2021    3
disabled: 15/02/2021    3
disabled: 17/02/2021    4
disabled: 22/02/2021    4
active: 22/02/2021      5
active: 22/02/2021      5
active: 04/02/2021      6
active: 22/02/2021      6
active: 22/02/2021      7
active: 22/02/2021      7
active: 05/02/2021      7
active: 22/02/2021      8 
active: 22/02/2021      8
active: 22/02/2021      9
active: 22/02/2021      9

在这种特定情况下,我有 2 个 ID 分别为 4 和 3 的帐户,总共 4 行,但我希望计数的结果是禁用的帐户数,在这种情况下为 2

我尝试了失败:

=COUNTIFS('mysheet'!S2:S, "active")
=COUNTUNIQUEIFS('mysheet'!S2:S, 'mysheet'!C2:C,"disabled")

【问题讨论】:

    标签: sql google-sheets spreadsheet counting countif


    【解决方案1】:

    试试这个:

    =COUNTUNIQUEIFS(C2:C; A2:A; "disabled*")
    

    即使 A 列包含日期也有效

    【讨论】:

      【解决方案2】:

      从您提供的数据来看,disabled: <date> 在单列中,因此我们需要在使用 count 之前修剪或使用正则表达式删除日期:

      =COUNTUNIQUE(REGEXEXTRACT(A7:A,"(.*):.*"),"disabled")
      

      或

      =COUNTUNIQUE(TRIM(LEFT(A7:A,FIND("disabled",A7:A))),"disabled")
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-10-27
        • 2019-11-23
        • 2014-07-30
        • 1970-01-01
        • 2015-06-21
        • 1970-01-01
        • 2019-03-19
        • 1970-01-01
        相关资源
        最近更新 更多