【问题标题】:Google Sheet combining two/three sets of col and calculate unique values with eachGoogle Sheet 结合两/三组 col 并计算每组的唯一值
【发布时间】:2023-03-11 07:22:02
【问题描述】:

我有以下

col1    col2    col3   col4
NY      sys1    DB1    4
CA      sys1    DB1    2
CA      sys1    DB1    1
MI      sys1    DB1    1
DC      sys1    DB2    2
MI      sys1    DB2    2

在谷歌表格中,我希望输出看起来像这样。注意:DB1 中的记录需要单独计算,DB2 单独计算,但在每个 DB 中是唯一的,并且输出我不想对每条记录重复 DB1,因为下一个 col 中的所有记录都来自 DB1。只显示 DB1 一个,然后当 DB 发生变化时,再显示一次新的,并显示和统计自己的记录

DB1    NY    4
       CA    3
       MI    1
DB2    DC    2
       MI    2

我尝试了建议的公式,但它一直给我解析错误,不确定我做错了什么 Here is what I a typing

我的实际情况如下:当然,col B 在快照中显示了相同的数据,但是由于其他值下降了,因此无法捕获其他不同的值。请假设 Col B 有不同的值。

My actual data

【问题讨论】:

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


    【解决方案1】:

    尝试:

    =ARRAYFORMULA({IF(COUNTIFS(
     QUERY(QUERY(A:D, "select C,A,sum(D) where A !='' group by C,A label sum(D)''", 0), "select Col1", 0), 
     QUERY(QUERY(A:D, "select C,A,sum(D) where A !='' group by C,A label sum(D)''", 0), "select Col1", 0), ROW(INDIRECT("F1:F"&COUNTA(
     QUERY(QUERY(A:D, "select C,A,sum(D) where A !='' group by C,A label sum(D)''", 0), "select Col1", 0)))), "<="&ROW(INDIRECT("F1:F"&COUNTA(
     QUERY(QUERY(A:D, "select C,A,sum(D) where A !='' group by C,A label sum(D)''", 0), "select Col1", 0)))))=1, 
     QUERY(QUERY(A:D, "select C,A,sum(D) where A !='' group by C,A label sum(D)''", 0), "select Col1", 0), ),
     QUERY(QUERY(A:D, "select C,A,sum(D) where A !='' group by C,A label sum(D)''", 0), "select Col2,Col3", 0)})
    


    欧盟语法:

    =ARRAYFORMULA({IF(COUNTIFS(
     QUERY(QUERY(A:D; "select C,A,sum(D) where A !='' group by C,A label sum(D)''"; 0); "select Col1"; 0); 
     QUERY(QUERY(A:D; "select C,A,sum(D) where A !='' group by C,A label sum(D)''"; 0); "select Col1"; 0); ROW(INDIRECT("F1:F"&COUNTA(
     QUERY(QUERY(A:D; "select C,A,sum(D) where A !='' group by C,A label sum(D)''"; 0); "select Col1"; 0)))); "<="&ROW(INDIRECT("F1:F"&COUNTA(
     QUERY(QUERY(A:D; "select C,A,sum(D) where A !='' group by C,A label sum(D)''"; 0); "select Col1"; 0)))))=1; 
     QUERY(QUERY(A:D; "select C,A,sum(D) where A !='' group by C,A label sum(D)''"; 0); "select Col1"; 0); )\
     QUERY(QUERY(A:D; "select C,A,sum(D) where A !='' group by C,A label sum(D)''"; 0); "select Col2,Col3"; 0)})
    

    【讨论】:

    • 不工作。请查看添加到问题中的其他详细信息
    猜你喜欢
    • 2012-02-10
    • 2019-06-18
    • 1970-01-01
    • 2022-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-16
    相关资源
    最近更新 更多