【问题标题】:How can values imported with ImportJSON be converted to numerical values?使用 ImportJSON 导入的值如何转换为数值?
【发布时间】:2020-04-08 01:55:21
【问题描述】:

我发现使用 ImportJSON 导入 Google 电子表格的值不是数字。它们是文本(现在对我来说很明显),不能相加。

如何转换?我尝试将单元格格式更改为数字,但它什么也没做。

导入是

=ImportJSON("https://api.liquid.com/executions?product_id=1&limit=10")

我希望对第 4 列的模型数量求和,但总数为零。

【问题讨论】:

  • 关于I have tried changing the Cell Format to numeric, but it does nothing.,能否提供详细信息?例如,我认为如果你能提供你期望的样本输入和输出值,它将帮助用户思考解决方案。
  • 感谢您更新它。虽然我不确定我是否能正确理解你的情况和目标,但是为了在models 的数组中求和quantity 的值,使用=SUM(ARRAYFORMULA(VALUE(ImportJSON("https://api.liquid.com/executions?product_id=1&limit=10","/models/quantity", "noInherit,noTruncate,noHeaders")))) 的公式怎么样?

标签: arrays json google-sheets array-formulas


【解决方案1】:

知道了!再次使用正则表达式。

=ArrayFormula(REGEXREPLACE(D2:D11, "[^\d\.]+",)*1)

然后对生成的新数值列求和。

来源:How to Convert Currency Text to Number in Google Sheets

注意:您必须更改示例中使用的花哨的双引号。

【讨论】:

    【解决方案2】:

    尝试:

    =INDEX(IMPORTJSON("https://api.liquid.com/executions?product_id=1&limit=10")*1)
    

    或者如果您看到错误:

    =INDEX(IFERROR(
     IMPORTJSON("https://api.liquid.com/executions?product_id=1&limit=10")*1;     
     IMPORTJSON("https://api.liquid.com/executions?product_id=1&limit=10")))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-19
      • 1970-01-01
      • 2015-09-13
      • 2017-08-25
      • 1970-01-01
      相关资源
      最近更新 更多