我正在使用公式计算Google工作表中的Google财经200天移动平均公式
=平均值(query(sort(GoogleFinance(“GOOG”,“price”,TODAY()-320,TODAY()),1,0),“select Col2 limit 200”)))
然后在谷歌应用程序脚本中我在变量中获取上述单元格值,如下所示
var val = sheet.getRange(“T101”)。getValue();
但是在谷歌脚本中,我得到的变量值为 #NA 。谁能告诉我是什么引起了这个问题?
最佳答案
为了扩展@Ric ky的答案,这里的技巧是达到一个范围,以便可以对它进行平均数学运算。
对于此工作答案:=AVERAGE(INDEX(GoogleFinance("GOOG","all",WORKDAY(TODAY(),-200),TODAY()),,3))
这是它起作用的原因:
=AVERAGE(
INDEX( // used to get 1 value or a range of values from a reference
GoogleFinance("GOOG","all",WORKDAY(TODAY(),-200),TODAY()), // returns an expanded array with column headers, used by INDEX as the reference
, // bypass INDEX's row argument to return an entire column to be AVERAGE'd
3 // we want the High column with an index of 3; index is 1-based
)
)
视觉效果:
关于google-apps-script - Google Finance 200天移动平均线在Apps脚本中获得#NA,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44610508/