Don't miss your chance to take exam DP-600 or DP-700 on us!
Request nowLearn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
Hi
I am using the Canvas LMS API and am struggling with a pagination issue. Using a few tutorials and posts from here I have managed to make some progress but haven’t quite nailed it.
Using the following query I am able to iterate through the pages of the endpoint I’m calling but the query loops endlessly.
let
Query1 = List.Generate(()=>
[Result = try fComments(1) otherwise null, Page=1],
each [Result] <> null and [Page] < 10,
each [Result = try fComments([Page]+1) otherwise null, Page=[Page]+1],
each [Result])
in
Query1
To stop this I added the [Page] < 10 condition and it now stops after 9 iterations and I can see the data I expect is being returned. Each call to the endpoint returns a list. The first few lists contain the data I want as expected but subsequent calls return empty lists. Whilst this is usable it is not ideal.
This is what is returned
Using Postman I can confirm that API calls to page numbers that don’t have data don’t return an error but rather return an empty list.
I need a way to add a condition that stops the loop when an empty list is returned but have not been able to work it out. Any help is appreciated.
Thanks
Solved! Go to Solution.
Try changing your condition to the following.
each List.Count([Result]) > 0 and [Page] < 10
Pat
Thanks Pat
That worked, greatly appreciated
Cheers
Try changing your condition to the following.
each List.Count([Result]) > 0 and [Page] < 10
Pat
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Check out the February 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 11 | |
| 8 | |
| 7 | |
| 5 | |
| 5 |