我有两列,我想获得一个独特的地方列表,其中包含下一栏中的总和。
例如:
当前
Places (ColumnA) Count(ColumnB)
Italy, Greece, France 10
Italy, Greece 5
France 1
期望的结果
Places (ColumnD) Count(ColumnE)
Italy 15
Greece 15
France 11
答案 0 :(得分:3)
假设您的数据从第2行开始,请尝试使用D2:
=ArrayFormula({unique(trim(transpose(split(concatenate(A2:A&","),",")))),sumif(A2:A, "=*"&unique(trim(transpose(split(concatenate(A2:A&","),","))))&"*",B2:B)})
或者,或者:
=query(ArrayFormula({transpose(split(query(substitute(A2:A,",",""),,50000)," ")),transpose(split(concatenate(rept(B2:B&char(9), len(A2:A)-len(substitute(A2:A, ",",""))+1 )),char(9)))}), "select Col1, sum(Col2) where Col1 <>'' group by Col1 label sum(Col2)'' ")
另一种方式(对于AdamL来说就是这个):
=ArrayFormula(QUERY(TRANSPOSE(SPLIT(QUERY(REPT(A2:A&", ",B2:B),,ROWS(A2:A)),", "))&{"",""},"select Col1, count(Col2) group by Col1 label count(Col2) ''",0))