Forum Discussion

bikelley's avatar
bikelley
Helper IV
4 years ago
Solved

How to create a custom dynamic list for REST API pagination?

Hello,  I am trying to create a dynamic list that increments by 2000 until it meets the Total Result Count. Please see below for my initial API result.    I have tried a few options and did ...
  • PhilipTreacy's avatar
    4 years ago

    Hi bikelley 

     

    Download example PBIX file

     

    This code will create your list

    let
        Source = Record.FromList({12958},{"TotalResultCount"}),
        TotalResultCount = Source[TotalResultCount],
        DynamicList = List.Generate(() => 2000, each _ < TotalResultCount, each _ + 2000),
        FinalList = List.Combine({DynamicList, {TotalResultCount}})
    in
        FinalList

     

     

     

    I've set up a dummy record in the Source step so that I can simulate getting the TotalResultCount.  You can modify this to suit your own query structure.

     

    Regards

     

    Phil

     

     

  • PhilipTreacy's avatar
    4 years ago

    Hi bikelley 

     

    Change the FinalList step to this

    FinalList = List.Combine({{1}, DynamicList, {TotalResultCount}})

     

    Regards

     

    Phil