算上所有苹果和好苹果

时间:2018-03-13 23:42:54

标签: excel excel-formula google-sheets countif

在Google表格上,我目前有一个看起来像是" raw"表:

RAW:

Week Starting   Date    Apple type
12/31/2017  1/4/2018    Green
12/31/2017  1/5/2018    Green
1/7/2018    1/8/2018    Bad - Green
1/7/2018    1/8/2018    Bad - Green
1/7/2018    1/8/2018    Yellow
1/7/2018    1/9/2018    Green
1/7/2018    1/9/2018    Red
1/7/2018    1/9/2018    Red
1/7/2018    1/10/2018   Green
1/7/2018    1/10/2018   Yellow
1/7/2018    1/10/2018   Bad - Yellow
1/7/2018    1/12/2018   Yellow
1/14/2018   1/16/2018   Red
1/14/2018   1/16/2018   Yellow
1/21/2018   1/23/2018   Red
1/21/2018   1/23/2018   Bad - Red
1/21/2018   1/23/2018   Yellow

我想写一个返回如下内容的公式: 总结:

Week Starting   Count of all apples Count of only good apples
12/31/17                   2                  2
1/7/18                     10                 7
1/14/18                    2                  2
1/21/18                    3                  2

我尝试过使用减号,引号等组合的多个countifs,但仍然无法达到此目的。有人请给我一些提示吗? :/

2 个答案:

答案 0 :(得分:3)

这应该可以解决问题:

G2:=COUNTIF(A2:A18,F2)
H2:=G2-COUNTIFS($A$2:$A$18,F2,$C$2:$C$18,"*Bad*")

enter image description here

这些公式也适用于Google表格

答案 1 :(得分:1)

=QUERY(FILTER({{A:B},{C1;IFERROR(REGEXEXTRACT(C2:C,"Bad"),"Good")}},A:A<>""),"select Col1, Count(Col2) group by Col1 pivot Col3", 1)

这是一个单一的公式解决方案,结果是表:

Week Starting   Bad Good
12/31/2017            2
1/7/2018          3   7
1/14/2018             2
1/21/2018         1   2
相关问题