Google-sheets – Select subrange of an array-returning formula like GOOGLEFINANCE()

google sheetsworksheet-function

In Google Sheets, GOOGLEFINANCE returns an array of values, like so:

array of results

The formula is entered in A1 but the result extends into other rows and columns. I would like to "select" (not sure what the exact term is) a subset of this data. For example, I would like to select only the prices, without header (so B2:B22 in the image above). And I would like to do that in one formula, without ever printing the full table.

I tried OFFSET, but it doesn't work since it doesn't recognize the GOOGLEFINANCE formula as a range. Conversely, INDEX works, but only returns one cell at a time, so

 INDEX(GOOGLEFINANCE("TSLA", "price", TODAY()-30, TODAY(), "DAILY"),2,2)

returns "345.66" for example.

Best Answer

You could use INDEX without a row parameter to return a column

For example,

=INDEX(GOOGLEFINANCE("TSLA", "price", TODAY()-30, TODAY(), "DAILY"),,2)

will return the second column fully. However, To fully manipulate the array, you can use QUERY:

 =QUERY(GOOGLEFINANCE("TSLA", "price", TODAY()-30, TODAY(), "DAILY"), "Select Col1,Col2 where Col2>355 limit 6 offset 1",0)

Here I've made the following conditions:

  • πŸ„ΏπŸ…πŸ„ΈπŸ„²πŸ„΄ more than γ€Ž355』(Remove where Col2>355 if you don't need it )
  • Total πŸ„»πŸ„ΈπŸ„ΌπŸ„ΈπŸ…ƒ of rows =5
  • πŸ„ΎπŸ„΅πŸ„΅πŸ…‚πŸ„΄πŸ…ƒ the first row