I want to get the dividend of companies like ENG.MC or other stock like GSY.TO, but Sheets did not find the dividend.
i put on my Google Sheet:
=IMPORTXML($D$25;D24)
I want the "Forward Dividend & Yield" from Yahoo but i recieved a #N/A
example of the error
Related
I am trying to get stock info from Yahoo Finance with the function importxml in google sheets. How can I get to the revenue row?
https://finance.yahoo.com/quote/AMZN/financials?p=AMZN
From this page I would like to go down to income statement and get total revenue for the last 3 years.
First I click inspect the page and copy the full xpath. Then I add it to the formula importxml in google sheets:
=IMPORTXML(
"https://finance.yahoo.com/quote/AMZN/financials?p=AMZN";
"/html/body/div[1]/div/div/div[1]/div/div[3]/div[1]/div/div[2]/section/div[3]/div[1]/div/div[2]/div[1]/div[1]/div[2]")
but it says:
#N/A Error - Resource at url not found
Having value error in google sheet, within pivot table, calculated field. Using the formula
=SUM("Box Office Revenue ($)")/COUNT("Box Office Revenue ($)".
sounds like average:
=AVERAGE(A2:A)
I'm trying to import some Singapore stock prices from Yahoo finance in my Google sheets. I am using the code
=IMPORTXML("https://finance.yahoo.com/quote/" & A2,"//*[#id='quote-header-info']/div[3]/div[1]/div/span[1]")
and put the ticker in A2. It works for some SGX stocks but not the others. Applying to STI constituents, I got something like
Ticker
Price
D05.SI
28.4
O39.SI
11.61
U11.SI
#N/A
Z74.SI
2.41
J36.SI
#N/A
A17U.SI
3.05
C38U.SI
#N/A
Y92.SI
#N/A
S68.SI
#N/A
C31.SI
3.75
...
...
I have checked that for U11.SI and J36.SI, the XPATH of the price element is the same as for D05.SI. Below is the link to the Google sheet
https://docs.google.com/spreadsheets/d/1Tp9leC43J1W3Jun3Z23K51zmbkZRhPOcM60ffBPOs90/edit?usp=sharing
Could anyone shed some light on what's going wrong here? Thanks!
You can pull in data from Yahoo Finance quite easily using Google Apps Script. In the Apps script, you can define a function to retrieve data from any web page and then parse the HTML output.
function yahooF() {
const ticker = 'AAPL';
const url = `https://finance.yahoo.com/quote/${ticker}?p=${ticker}`;
const res = UrlFetchApp.fetch(url, {muteHttpExceptions: true});
const contentText = res.getContentText();
const price = contentText.match(/<fin-streamer(?:.*?)data-test="qsp-price"(?:.*)>(\d+\.\d+)<\/fin-streamer>/);
console.log(price[1]);
return price[1];
}
In the above snippet, Yahoo Finance's page on Apple's stock is retrieved using UrlFetchApp. The price of the ticker is then extracted using regex and one can get Apple's stock price in a Google sheet by using the defined =yahooF() function.
I explained this more in-depth in an article on Medium.
I have created a master sheet which imports the data for the other sheets which are representing the dates of the month. In the sheet the master sheet cell A2 has the formula to import from the other sheets which the google sheet
Google Spread Sheet.
The issue I am facing is that if in the formula I change the sheet 10 range from A2:CH to A2:CO it gives an error
Error
In ARRAY_LITERAL, an Array Literal was missing values for one or more rows.
I am not being able to find the problem as this is not a permissions issue and neither does sheet 10 have any data in this case.
full code is below:
=UNIQUE(query({'1'!A2:CO;'2'!A2:CO;'3'!A2:CO;'4'!A2:CO;'5'!A2:CO;'6'!A2:CO;'7'!A2:CO;'8'!A2:CO;'9'!A2:CO;'10'!A2:CO;'11'!A2:CO;'12'!A2:CO;'13'!A2:CO;'14'!A2:CO;'15'!A2:CO;'16'!A2:CO;'17'!A2:CO;'18'!A2:CO;'19'!A2:CO;'20'!A2:CO;'21'!A2:CO;'22'!A2:CO;'23'!A2:CO;'24'!A2:CO;'25'!A2:CO;'26'!A2:CO;'27'!A1:CO;'28'!A2:CO;'29'!A2:CO;'30'!A2:CO;'31'!A2:CO},"select * where Col1 is not null"))
This code calculates a sum of string lengths in the range H1:V5 using G as a row index and C as a column index. It works perfectly in Excel:
{=SUMPRODUCT(LEN(INDEX(H1:V5,N(IF({1},ROW(G2:G5))),N(IF({1},C2:C5+1))))*ISNUMBER(G2:G5))}
But when I try it in Google Sheets it doesn't work although Google Sheets recognizes all commands. Is it possible to convert my formula to Google Sheets? Or maybe there is some workaround to get the same result there?
Open with Google Sheets returns incorrect result:
=ARRAY_CONSTRAIN(ARRAYFORMULA(SUMPRODUCT(LEN(INDEX(H1:V5,N(IF({1},ROW(G2:G5))),N(IF({1},C2:C5+1))))*ISNUMBER(G2:G5))), 1, 1)
Unfortunately the construct index...n(if({1}... is peculiar to Excel.
The vlookup function in Google sheets is very versatile and you can use that instead:
=SUMPRODUCT(len(vlookup(row(H1:K5),{row(H1:K5),H1:K5},C1:C5+2,false))*isnumber(G1:G5))