Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I have a function that lists parameters and then uses them to paginate/offset an api query when invoked. This works fine, but I want to set them up so that I can adjust the parameters without invoking the function and creating a new query/dataset everytime. So, I set the same parameters up using the UI but now my pagination does not work.
I'm wondering if there is some key difference between the two types of parameter, or more likely, what I'm missing that is causing it to break.
Here is the code that works;
let
Source = (maxrecords as number, limitoffset as number, Token, optional query) =>
if query = null or query = ""
then List.Generate(
()=>[Counter = 0],
each [Counter] < maxrecords,
each [Counter = [Counter] + limitoffset],
each Json.Document(Web.Contents("'URL'/api?limit=" & Number.ToText(limitoffset) & "&offset=" & Number.ToText([Counter]), [Headers=[ContentType="application/json", Authorization="Bearer " & Token]])))
else List.Generate(
()=>[Counter = 0],
each [Counter] < maxrecords,
each [Counter = [Counter] + limitoffset],
each Json.Document(Web.Contents("'URL'/api?limit=" & Number.ToText(limitoffset) & "&offset=" & Number.ToText([Counter]) & "&" & query, [Headers=[ContentType="application/json", Authorization="Bearer " & Token]])))
in
Source
And this code (with the parameters set through the UI) only returns a single page of data.
let
Source = if query = null or query = ""
then List.Generate(
()=>[Counter = 0],
each [Counter] < maxrecords,
each [Counter = [Counter] + limitoffset],
each Json.Document(Web.Contents("'URL'/api?limit=" & Number.ToText(limitoffset) & "&offset=" & Number.ToText([Counter]), [Headers=[ContentType="application/json", Authorization="Bearer " & Token]])))
else List.Generate(
()=>[Counter = 0],
each [Counter] < maxrecords,
each [Counter = [Counter] + limitoffset],
each Json.Document(Web.Contents("'URL'/api?limit=" & Number.ToText(limitoffset) & "&offset=" & Number.ToText([Counter]) & "&" & query, [Headers=[ContentType="application/json", Authorization="Bearer " & Token]])))
in
Source
I'm sure there's something I'm just not seeing, but I thought it would be worth checking to see if there is some fundamental difference between the two types of parameter that is causing an issue.
Thanks for taking a look!
Hi @Anonymous ,
You could check if the parameter is decimal number in UI. After my tests, both of the methods could finish the cycle. So I think the problem is caused by parameter properties in UI.
@v-eachen-msft Thanks for testing it. I've tried them as Any and as Decimal Number and still no luck. My UI doesn't seem to have an option for just plain Number.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
100 | |
54 | |
21 | |
12 | |
11 |