【问题标题】:How to count unique values ​with the QUERY function of google sheets?如何用google sheet的QUERY功能统计唯一值?
【发布时间】:2021-08-27 15:24:15
【问题描述】:

我正在处理类似于下表的案例:

Producto Referencia Cantidad
PRODUCTO 1 1001 35
PRODUCTO 1 1001 29

我正在使用 QUERY 公式,我需要以下结果:

group by Producto count Referencia count unique Referencia sum Cantidad
PRODUCTO 1
PRODUCTO 2
PRODUCTO 3

有人知道怎么做吗?

【问题讨论】:

    标签: google-sheets google-sheets-formula


    【解决方案1】:

    根据您的语言环境,尝试:

    =arrayformula(query({A:C\if(countifs(A:A&"-"&B:B;A:A&"-"&B:B;row(B:B);"<="&row(B:B))=1;1;)};"select Col1,count(Col2),sum(Col4),sum(Col3) where Col1 is not null group by Col1 label Col1 'group by Producto',sum(Col4) 'count unique Referencia' ";1))
    

    【讨论】:

    • 非常感谢!如果数量列不存在而我只想要“按产品分组”、“计数引用”和“计数唯一引用”列怎么办?
    • =arrayformula(query({A:C,if(countifs(A:A&amp;"-"&amp;B:B,A:A&amp;"-"&amp;B:B,row(B:B),"&lt;="&amp;row(B:B))=1,1,)},"select Col1,count(Col2),sum(Col4) where Col1 is not null group by Col1 label Col1 'group by Producto',sum(Col4) 'count unique Referencia' ",1))
    猜你喜欢
    • 1970-01-01
    • 2022-11-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-28
    相关资源
    最近更新 更多