Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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&"®ion=...
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
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.
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&""®ion="®ionParam&"/"
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
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!