Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
jannie
Frequent Visitor

Using The RelativePath And Query Options With Web.Contents() In Power Query And Power BI M Code

Chris Webb wrote this great blog:

 

https://blog.crossjoin.co.uk/2021/01/10/handling-multiple-url-query-parameters-with-the-same-name-us...

 

I have 3 parameters in my Power BI Service Dataflow. I manually addede the parameters to the M-Code and the query works, until I make a function of it whereby I pass multiple parameters to it then I cannot save the dataflow, and get the following error: 

Can't save dataflow

One or more tables references a dynamic data source.

 

My code looks as follows:

"Source = Csv.Document(Web.Contents("https://query1.finance.yahoo.com/v7/finance/download/" & prmTicker & "?period1=" & prmStartDate & "&period2=" & prmEndDate & "&interval=1d"), [Delimiter = ",", Columns = 7, QuoteStyle = QuoteStyle.None])"
 
Does anyone know how to convert this to Chris' format, which looks something like this: 
"Web.Contents("http://jsonplaceholder.typicode.com/comments",[Query=[postId={"1","2"}]])"
 
Thanks
Jannie
 
1 ACCEPTED SOLUTION
jpessoa8
Continued Contributor
Continued Contributor

Hi @jannie ,

 

Since the ticker is not a parameter in the Yahoo Finance API (like period1, period2 and interval are) you cannot follow the approach of [Query=[...

 

Instead, you can used directly the RelativePath approach :

 

let
    Source = Csv.Document(Web.Contents("https://query1.finance.yahoo.com/v7/finance/download/", [RelativePath=prmTicker & "?period1="& prmStartDate & "&period2=" & prmEndDate & "&interval=1d"]),[Delimiter=",", Columns=7, Encoding=65001, QuoteStyle=QuoteStyle.None])
in
    Source

 

For documentation, if ticker was a parameter and you wanted to use the [Query=[... approach it will be like this:

 

let
    Source = Csv.Document(Web.Contents("https://query1.finance.yahoo.com/v7/finance/download/TSLA", [Query=[ticker = prmTicker, period1= prmStartDate, period2= prmEndDate, interval="1d"]]),[Delimiter=",", Columns=7, Encoding=65001, QuoteStyle=QuoteStyle.None])
in
    Source

 

Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudo 👍
Thanks!

You can also check out my LinkedIn!

Best regards,
Jorge Pessoa

View solution in original post

2 REPLIES 2
jpessoa8
Continued Contributor
Continued Contributor

Hi @jannie ,

 

Since the ticker is not a parameter in the Yahoo Finance API (like period1, period2 and interval are) you cannot follow the approach of [Query=[...

 

Instead, you can used directly the RelativePath approach :

 

let
    Source = Csv.Document(Web.Contents("https://query1.finance.yahoo.com/v7/finance/download/", [RelativePath=prmTicker & "?period1="& prmStartDate & "&period2=" & prmEndDate & "&interval=1d"]),[Delimiter=",", Columns=7, Encoding=65001, QuoteStyle=QuoteStyle.None])
in
    Source

 

For documentation, if ticker was a parameter and you wanted to use the [Query=[... approach it will be like this:

 

let
    Source = Csv.Document(Web.Contents("https://query1.finance.yahoo.com/v7/finance/download/TSLA", [Query=[ticker = prmTicker, period1= prmStartDate, period2= prmEndDate, interval="1d"]]),[Delimiter=",", Columns=7, Encoding=65001, QuoteStyle=QuoteStyle.None])
in
    Source

 

Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudo 👍
Thanks!

You can also check out my LinkedIn!

Best regards,
Jorge Pessoa

Excellent thanks Jorge it works perfectly and I now understand the syntax.

All the best

Jannie

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.