简体   繁体   English

查找数字并将其汇总到Google电子表格列中

[英]Find digits and sum them in a google spreadsheet column

I have a Google Spreadsheets with a column that can contains text like this: 我有一个Google电子表格,其中的一列可以包含以下文本:

+-----------------+
| running, 3.4 km |
+-----------------+
|                 |
+-----------------+
|                 |
+-----------------+
| running, 5.2 km |
+-----------------+
| running, 4.7 km |
+-----------------+
|                 |
+-----------------+

How can I search through this column and get the sum of the digits? 如何搜索此列并获得数字总和? (here 3.4+5.2+4.7) (这里是3.4 + 5.2 + 4.7)

Thanks! 谢谢!

If your example is in column A, then you can use the SPLIT() function or the REGEXEXTRACT() function. 如果您的示例在A列中,则可以使用SPLIT()函数或REGEXEXTRACT()函数。

Example 1: Using SPLIT() : 示例1:使用SPLIT()

           A                 B             B        C    D
  +-----------------+-----------------+----------+-----+----+
1 | running, 3.4 km | =SPLIT(A1, " ") | running, | 3.4 | km |
  +-----------------+-----------------+----------+-----+----+

Then use SUM() on column C . 然后在C列上使用SUM()


Example 2: Using REGEXEXTRACT() : 示例2:使用REGEXEXTRACT()

           A                        B                  B   
  +-----------------+-------------------------------+-----+
1 | running, 3.4 km | =REGEXEXTRACT(A1, "\d*.\.\d") | 3.4 |
  +-----------------+-------------------------------+-----+

Then use SUM() on column B . 然后在B列上使用SUM()

或一劳永逸:

=sum(ArrayFormula(iferror(regexextract(A2:A,"[0-9\.]+")+0)))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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