如何从包含多个值的单元格中计算一个值?

时间:2019-02-23 09:03:17

标签: google-sheets formula libreoffice-calc

我有一个包含单元格的表,其中包含用逗号分隔的多个值,如下所示:

+----------+
| Column A |
|----------|
| a, b     |
|----------|
| a, b, d  |
|----------|
| b, c     |
|----------|
| c, d, e  |
+----------+

我想得到一个表,该表对ab...e的数量进行计数,如下所示:

 +-----------------------+
 | Column A  | Column B  |
 |-----------------------|
 |     a     |     2     |
 |-----------------------|
 |     b     |     3     |
 |-----------------------|
 |     c     |     2     |
 |-----------------------|
 |     d     |     2     |
 |-----------------------|
 |     e     |     1     |
 +-----------------------+

是否有Google Sheets或LibreOffice Calc电子表格公式可以做到这一点?

3 个答案:

答案 0 :(得分:1)

  • C1: =UNIQUE(TRANSPOSE(SPLIT(TEXTJOIN(" ,",1,A:A)," ,")))

  • D1: =ARRAYFORMULA(IF(LEN(C:C),COUNTIF(A:A,"=*"&C:C&"*"),))

答案 1 :(得分:0)

=QUERY(TRANSPOSE(SPLIT(TEXTJOIN(" ,",1,A:A)," ,")),
 "select Col1, count(Col1) 
  where Col1 is not null 
  group by Col1 
  label count(Col1) ''")

enter image description here

答案 2 :(得分:0)

={UNIQUE(TRANSPOSE(SPLIT(TEXTJOIN(" ,",1,A:A)," ,"))),
 ARRAYFORMULA(IF(LEN(UNIQUE(TRANSPOSE(SPLIT(TEXTJOIN(" ,",1,A:A)," ,")))),
 COUNTIF(A:A,"=*"&UNIQUE(TRANSPOSE(SPLIT(TEXTJOIN(" ,",1,A:A)," ,")))&"*"),))}

3