I am using the following formula in Google Sheets to pull in some financial data:
=TRANSPOSE(IMPORTHTML("https://finance.yahoo.com/quote/MSFT/key-statistics?p=MSFT,"table",4))
The IMPORTHTML
result is
Forward Annual Dividend Rate 4 2.04
Forward Annual Dividend Yield 4 1.11%
Trailing Annual Dividend Rate 3 1.94
Trailing Annual Dividend Yield 3 1.05%
5 Year Average Dividend Yield 4 2.02
Payout Ratio 4 32.93%
Dividend Date 3 Mar 11, 2020
Ex-Dividend Date 4 Feb 18, 2020
Last Split Factor 2 2:1
Last Split Date 3 Feb 17, 2003
I am TRANSPOSING
the result to prepare the data for querying:
Forward Annual Dividend Rate 4 Forward Annual Dividend Yield 4 Trailing Annual Dividend Rate 3 ...
2.04 1.11% 1.94 ...
What I need is the value of the Ex-Dividend Date 4
column (so: Feb 18, 2020
) (and later also other columns so I am seeking a generic solution). I have tried multiple ways (see below, but all resulting in #VALUE!
errors:
=QUERY(TRANSPOSE(IMPORTHTML("https://finance.yahoo.com/quote/MSFT/key-statistics?p=MSFT","table",4)), "SELECT * LIMIT 2 OFFSET 1 WHERE COL=""Ex-Dividend Date 4"")")
=QUERY(TRANSPOSE(IMPORTHTML("https://finance.yahoo.com/quote/MSFT/key-statistics?p=MSFT","table",4)), "SELECT [Ex-Dividend Date 4] LIMIT 2 OFFSET 1")
How do I query this table correctly?
try:
=INDEX(IMPORTHTML("https://finance.yahoo.com/quote/MSFT/key-statistics?p=MSFT",
"table", 4), 8, 2)
or already formatted:
=TEXT(INDEX(IMPORTHTML("https://finance.yahoo.com/quote/MSFT/key-statistics?p=MSFT",
"table", 4), 8, 2), "mm/dd/yyyy")
in QUERY
:
=QUERY(IMPORTHTML("https://finance.yahoo.com/quote/MSFT/key-statistics?p=MSFT",
"table", 4), "select Col2 where Col1 contains 'Ex-Dividend Date 4'", 0)