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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! 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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.