Forum Discussion
Yahoo Finance Power Query Link Not Working
Hello,
Many thanks for your responses, it's much appreciated.
I've never used JSON... I tried the url in PowerQuery, but it's not clear what to do with it. What are the steps to get this into just a data table?
Also, my end date is (was) dynamic, i.e. previously, my query would search Yahoo Finance for today's date minus 1 day and return the data. How does one incorporate that into the query?
Essentially you need to change the source in your query.
In Power BI Use Transform Data, select the relevant query then use the Advanced Editor. You will see Source = xxxx
Previously the table was contructed as CSV it now needs to be JSON so in my case the source is...
Source = Json.Document(Web.Contents("https://query1.finance.yahoo.com/v8/finance/chart/" & StickerSymbol & "?period1=" & StartOfPeriod & "&period2=" & EndOfPeriod & "&interval=1d&events=history&includeAdjustedClose=true"))
- kar20221 year agoFrequent Visitor
Hi @G05DVD ,
Can you please help me?
I tried to follow the above, but unfortunatelly not fully successful. I am not good at "M".(StockQuote as text) as table =>
let
today = Duration.TotalSeconds(DateTime.LocalNow() - #datetime(1970,1,1,0,0,0)),
lastyear = Duration.TotalSeconds(Date.AddYears(DateTime.LocalNow(),-5) - #datetime(1970,1,1,0,0,0)),
Source = Json.Document(Web.Contents("https://query1.finance.yahoo.com",[RelativePath="v7/finance/download/"&StockQuote&"?period1="&Number.ToText(Number.Round(lastyear))&"&period2="&Number.ToText(Number.Round(today))&"&interval=1d&events=history&includeAdjustedClose=true"]),[Delimiter=",", Columns=7, Encoding=65001, QuoteStyle=QuoteStyle.None]),
#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Date", type date}, {"Open", type number}, {"High", type number}, {"Low", type number}, {"Close", type number}, {"Adj Close", type number}, {"Volume", Int64.Type}})
in
#"Changed Type"