2

I'm looking to append the current share price of a stock to the end of a period with changing durations.

My current formula for the historical prices is (where cell B3 is a duration of days to retrieve): =GOOGLEFINANCE("AAPL","price",TODAY()-B3,TODAY())

Using the below formulae as shown below returns the current trading price in the same format as the historical prices:
=ARRAYFORMULA({TODAY(),GOOGLEFINANCE("AAPL","price")})

Combining the above formulas results in a "#N/A" error:
=ARRAYFORMULA({GOOGLEFINANCE("AAPL","price",TODAY()-B3,TODAY())},ARRAYFORMULA({TODAY(),GOOGLEFINANCE("AAPL","price")}))

How can I append today's current trading price to the retrieved historical range when that range is dynamic?

1 Answer 1

3

The formula is failing because you are giving arrayformula() two expressions when it only expects one. One of the { array expressions } is also superfluous. It is probably easier to do this with vstack(), like this:

=vstack( 
  googlefinance("AAPL", "price", today() - B3, today()), 
  { today(), googlefinance("AAPL", "price") } 
)

See vstack().

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.