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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
JoeKlp
New Member

Calculated URL string not working with Web.BrowserContents in function

We need to get tables from several web pages that are numbered, so we have a function with a parameter named PageNumber, like so:

 

= (PageNumber as text)=>
let
Source = Web.BrowserContents("https://myDomain.com/?page="&PageNumber&"&region=...

 

Now, we stored the original URL, the one with ".../?page =1& region=..." in a parameter, so we can change it, if needed.

To use this URL parameter inside the function, we insert the function's parameter name in the URL string, like so:

 

Text.Replace(#"URL","?page=1","?page=""&PageStart&""")

 

We end up with a string that is exactly the same as the one in the function's Source above.

We want to use this string with Web.BrowserContents in the function, but it gives us a

"DataSource.Error: Invalid URI: The URI scheme is not valid"

error, even though the string is the same as the one we paste in there.

 

How can we use a parameter to store the original URL and modifiy it to be used inside the custom function?

 

Thanks

2 REPLIES 2
Ehren
Microsoft Employee
Microsoft Employee

In your function, you have an M expression that will dynamically concatenate the URL with the page number.

 

Your second example is generating a text value. It's not an M expression, and thus won't be dynamically evaluated.

 

To illustrate the difference, try evaluating the following two expressions in the formula bar of a blank query:

= 1 + 1

vs.

= "1 + 1"

 

These may look the same, but they're actually completely different. The first one is an addition expression. The second one is a text value that contains the text of an M addition expression.

Anonymous
Not applicable

Well, I would just respectfully advise that you are playing with fire by adding quotes into your text parameters. I understand why you are doing it--to unquote and then requote the url so you can add the parameter to the string.

Instead, put the quotes at the Web.Contents level, where your text parameters can always be entered as "https://www.url.com/?page="&StartPage&""&region="&regionParam&"/"

 

Since you are using Text.Replace to get your url parameter, you should just get the Text.BeforeDelimiter, and use "?page=" as your delimiter.

 

Know what I'm saying?

 

--Nate

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.