So I have data in the following format:
I want to summarize this into another sheet like this:
So I can use TRANSPOSE(SPLIT(A1:A))
to do this individually
I can use ARRAYFORMULA(SPLIT(A:A))
to run this over a range, however I cant seem to use both of them together to the same effect
To summarize
Column A contains comma seperated values for car names
I want to get all the car names as rows in another sheet and add counts against them
You can get the whole mini-report with this one formula:
=ArrayFormula(QUERY(FLATTEN(TRIM(SPLIT(A2:A,","))),"Select Col1, COUNT(Col1) Where Col1 > '@' GROUP BY Col1 LABEL COUNT(Col1) ''"))
SPLIT
will split every entry in A2:A at the comma (if there is one) and will result in an error for every blank row (dealt with later).
TRIM
removes the spaces after any comma-splits.
FLATTEN
creates one column from all results (words, blanks and errors).
QUERY(...,"Select Col1, COUNT(Col1) Where Col1 > '@' GROUP BY Col1 LABEL COUNT(Col1) ''")
starts with everything in that FLATTEN
column and a COUNT
of each GROUP
ed by the name ruling out anything WHERE
the value in Col1 is not > the '@' symbol (which will rule out all blanks and errors). Finally, LABEL
will get rid of the superfluous header of "count" that would otherwise be generated for the COUNT(Col1)
column of the QUERY
.
Alternatively, you could rule out the errors first with a FILTER
and then use the WHERE
part of the QUERY
to rule out blanks:
=ArrayFormula(QUERY(FLATTEN(TRIM(SPLIT(FILTER(A2:A,A2:A<>""),","))),"Select Col1, COUNT(Col1) WHERE Col1 Is Not Null GROUP BY Col1 LABEL COUNT(Col1) ''"))
Managed to solve it from this question https://webapps.stackexchange.com/questions/114791/google-sheets-split-and-unique
=unique(transpose(arrayformula(trim(split(join(",",A1:A),",")))))
The most efficient is probably QUERY
. Unlike JOIN
, this has no limit on the number of characters in the result.
=ARRAYFORMULA(TRANSPOSE(SPLIT(
QUERY(A:A&",",,9^9),
", "
)))
=ARRAYFORMULA(UNIQUE(TRANSPOSE(SPLIT(
QUERY(A:A&",",,9^9),
", "
))))
=ARRAYFORMULA(QUERY(
TRANSPOSE(SPLIT(QUERY(A:A&",",,9^9),", ")),
"select Col1, count(Col1) group by Col1 label count(Col1)''"
))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.