cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Super User
Super User

Re: how to create a query that paginates?

I thought your problem was an error-message in the last item.

The code you're using skips the first element of the list. So this would return the full list:

 

let
Pagination = List.Buffer(List.Generate( () => [WebCall=[], Page = 1, Counter=0], // Start Value
   		each try Record.Field([WebCall],"next")<>null otherwise false or [Counter]=0, // Condition under which the next execution will happen
   		each [ WebCall = Json.Document(Web.Contents("http://py-soconnect.fusesport.com/api/members/for-season/250/?page="&Text.From([Page])&"")), // retrieve results per call
     			Page = [Page]+1,
     			Counter = [Counter]+1// internal counter
]
)),
    #"Converted to Table" = Table.FromList(Pagination, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in
    #"Converted to Table"

If that doesn't work and still the last element of your items is missing, you have to check the condition under which the next iteration happens: 

 

each try Record.Field([WebCall],"next")<>null otherwise false or [Counter]=0, // Condition under which the next execution will happen
   		

That has to match your specific API 

 

Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

Imke Feldmann

How to integrate M-code into your solution -- Check out more PBI- learning resources here -- Performance Tipps for M-queries




Anonymous
Not applicable

Re: how to create a query that paginates?

Thanks a lot @ImkeF.Working perfect now.