google spreadsheet - Getting the count of a column from a set of comma separated values? -
i have 2 columns , want list of unique places sum of count next column.
for example:
current
places (columna) count(columnb) italy, greece, france 10 italy, greece 5 france 1
desired outcome
places (columnd) count(columne) italy 15 greece 15 france 11
assuming data starts in row 2, try in d2:
=arrayformula({unique(trim(transpose(split(concatenate(a2:a&","),",")))),sumif(a2:a, "=*"&unique(trim(transpose(split(concatenate(a2:a&","),","))))&"*",b2:b)})
or, alternatively:
=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) col1 <>'' group col1 label sum(col2)'' ")
yet way (credits adaml one):
=arrayformula(query(transpose(split(query(rept(a2:a&", ",b2:b),,rows(a2:a)),", "))&{"",""},"select col1, count(col2) group col1 label count(col2) ''",0))
Comments
Post a Comment