我正在尝试使用自动总和来计算总数。我不知道在多于一个自动求和公式时如何使用countif
数据。
countif
用于计算一组固定类别的出现,这些类别可以通过带有数据验证的下拉菜单选择。因为在我的案例中有5个选项,所以最终的计算单元有5个countif
。但是,有5列具有相同的设置,我希望能够总计数据。
=CONCATENATE("Jeans: "&COUNTIF(J19:J29, "Jeans"), " " ,"C&J: "&
COUNTIF(J18:J29, "Coats & Jackets"), " " ,"Tops: "&
COUNTIF(J18:J29, "Tops"), " " ,"Drs: "&
COUNTIF(J18:J29, "Dresses & Skirts"), " " ,"Acs: "&
COUNTIF(J18:J29, "Accessories"))
以上代码的返回结果如下:
Jeans: 0 C&J: 0 Tops: 0 Drs: 0 Acs: 0
仅将单元格加在一起是行不通的。现在,我试图弄清楚如何提取每个值。
将所有5列加在一起,我希望这样:
Month total: Jeans: 30 C&J: 12 Tops: 45 Drs: 4 Acs: 10
最终,我希望能够将每个总数加在一起以获得一个总计。
答案 0 :(得分:1)
=CONCATENATE("Month total: Jeans: "&
INDEX(QUERY({SPLIT(LOWER(A1),"jeansctopsdra :&");
SPLIT(LOWER(B1),"jeansctopsdra :&");
SPLIT(LOWER(C1),"jeansctopsdra :&");
SPLIT(LOWER(D1),"jeansctopsdra :&");
SPLIT(LOWER(E1),"jeansctopsdra :&")},
"select sum(Col1),sum(Col2),sum(Col3),sum(Col4),sum(Col5)
label sum(Col1)'',sum(Col2)'',sum(Col3)'',sum(Col4)'',sum(Col5)''",0),1,1)&
" C&J: "&
INDEX(QUERY({SPLIT(LOWER(A1),"jeansctopsdra :&");
SPLIT(LOWER(B1),"jeansctopsdra :&");
SPLIT(LOWER(C1),"jeansctopsdra :&");
SPLIT(LOWER(D1),"jeansctopsdra :&");
SPLIT(LOWER(E1),"jeansctopsdra :&")},
"select sum(Col1),sum(Col2),sum(Col3),sum(Col4),sum(Col5)
label sum(Col1)'',sum(Col2)'',sum(Col3)'',sum(Col4)'',sum(Col5)''",0),1,2)&
" Tops: "&
INDEX(QUERY({SPLIT(LOWER(A1),"jeansctopsdra :&");
SPLIT(LOWER(B1),"jeansctopsdra :&");
SPLIT(LOWER(C1),"jeansctopsdra :&");
SPLIT(LOWER(D1),"jeansctopsdra :&");
SPLIT(LOWER(E1),"jeansctopsdra :&")},
"select sum(Col1),sum(Col2),sum(Col3),sum(Col4),sum(Col5)
label sum(Col1)'',sum(Col2)'',sum(Col3)'',sum(Col4)'',sum(Col5)''",0),1,3)&
" Drs: "&
INDEX(QUERY({SPLIT(LOWER(A1),"jeansctopsdra :&");
SPLIT(LOWER(B1),"jeansctopsdra :&");
SPLIT(LOWER(C1),"jeansctopsdra :&");
SPLIT(LOWER(D1),"jeansctopsdra :&");
SPLIT(LOWER(E1),"jeansctopsdra :&")},
"select sum(Col1),sum(Col2),sum(Col3),sum(Col4),sum(Col5)
label sum(Col1)'',sum(Col2)'',sum(Col3)'',sum(Col4)'',sum(Col5)''",0),1,4)&
" Acs: "&
INDEX(QUERY({SPLIT(LOWER(A1),"jeansctopsdra :&");
SPLIT(LOWER(B1),"jeansctopsdra :&");
SPLIT(LOWER(C1),"jeansctopsdra :&");
SPLIT(LOWER(D1),"jeansctopsdra :&");
SPLIT(LOWER(E1),"jeansctopsdra :&")},
"select sum(Col1),sum(Col2),sum(Col3),sum(Col4),sum(Col5)
label sum(Col1)'',sum(Col2)'',sum(Col3)'',sum(Col4)'',sum(Col5)''",0),1,5))