Forum Discussion

Falaerm's avatar
Falaerm
Frequent Visitor
3 years ago

How to do scrapping with 2 functions that determine the interval period and the different quotes?

Hello,

 

I have a Power BI Desktop with url data source from yahoo finance and one excel file for using a funciton. I am following a tuto how to do scrapping with data from Yahoo finance and I managed to create a table, but now I would like to add a function that let me to choose and change the interval period ("d", "wk","mo") of my data source from the yahoo fiannce url. The letter in Red and bold is the letter I need to change in the Url. I tried to creat another fuinction or create a double function but nothing worked...At the end I want to have a slicer that let me chosse the period (daily, weekly, monthly).

File (Soft Commodity Tab)

Power Bi File 

(SoftQuote as text) as table=>

let
Source = Csv.Document(Web.Contents("https://query1.finance.yahoo.com/v7/finance/download/"&SoftQuote&"?period1=1658534400&period2=1690070400&interval=1d&events=history&includeAdjustedClose=true"),[Delimiter=",", Columns=7, Encoding=65001, QuoteStyle=QuoteStyle.None]),
#"En-têtes promus" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
#"Valeur remplacée" = Table.ReplaceValue(#"En-têtes promus",".",",",Replacer.ReplaceText,{"Open", "High", "Low", "Close", "Adj Close", "Volume"}),
#"Type modifié" = Table.TransformColumnTypes(#"Valeur remplacée",{{"Open", type text}, {"High", type text}, {"Low", type text}, {"Close", type text}, {"Adj Close", type text}, {"Volume", Int64.Type}})
in
#"Type modifié"

 Many thanks ,

 

Romain

3 Replies