首页 文章

Google财经200天移动平均值在Apps脚本中以#NA形式出现

提问于
浏览
2

我正在使用公式计算谷歌财务中的谷歌财务200天移动平均公式

=average(query(sort(GoogleFinance("GOOG","price", TODAY()-320, TODAY()),1,0),"select Col2 limit 200"))

然后在谷歌应用程序脚本中我将变量中的上述单元格值如下所示

var val = sheet.getRange("T101").getValue();

但在谷歌脚本我得到的变量值为 #NA . 任何人都可以请问是什么导致了这个问题?

2 回答

  • 0

    为了扩展@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 ) )

    视觉:

    enter image description here

  • -1
    =AVERAGE(INDEX( GoogleFinance( "GOOG", "all" , WORKDAY( TODAY(), -200 ) , TODAY() ) , , 3))
    

相关问题