The following Apps Script does not retrieve the calculated value for a formula of =max(index(googlefinance(A2,"close","1/2/2018",today()),0,2))
. The logger shows #REF!
.
Anything wrong? I'm guessing it's related to the index()
but no idea how to proceed further.
1) Opening the sheet in a browser would show a calculated value at cell B2. The cell calculates the stock's YTD high price.
column_A column_B
row_1 symbol YTD High
row_2 SPY =max(index(googlefinance(A2,"close","1/2/2018",today()),0,2))
2) script:
function getStock(location) {
var sheet = SpreadsheetApp.getActiveSheet();
var activeRange = sheet.getDataRange();
var values = activeRange.getDisplayValues();
var formula = activeRange.getFormulas();
Logger.log(values[0]);
Logger.log(values[1]);
Logger.log(formula[1]);
}
3) logger output:
[18-05-22 14:48:10:431 PDT] [symbol, YTD High]
[18-05-22 14:48:10:432 PDT] [SPY, #REF!]
[18-05-22 14:48:10:433 PDT] [,
=max(index(googlefinance(A2,"close","1/2/2018",today()),0,2))]