简体   繁体   中英

How to select specific column from imported table?

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM