简体   繁体   中英

How do I retrieve the most frequent text value in a column that has cells with multiple entries in Google sheets?

I have a column with data (movie genres in this case) that looks like this:

| Drama                     |
| Action, Drama             |
| Action, Adventure, Drama  |

I am trying to get the most frequent occurring value, which is 'Drama' in this case. I came up with the following formula as a beginning but even that doesn't do what I want it to do.

ARRAYFORMULA(COUNT(UNIQUE(TRIM(SPLIT(A1:A3, ",")))))

This returns 0 but I want it to return 3 in this case and then find the most frequent unique value. Any ideas?

Basic case

=QUERY(index(if({1,1},TRANSPOSE(SPLIT(JOIN(", ",FILTER(A:A,A:A<>"")), ", ")))), "select Col1, count(Col2) group by Col1 order by count(Col2) desc")

在此处输入图片说明

Notes:

  • transpose + split + join is to get the line with all values
  • index + if({1,1}... is to double the column, for query to work. See this trick on sample file .
  • query is to select the most frequent values on the top.

Get only top value

use index:

=index (original_formula, 2, 1)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM