How to retrieve beyond 1000 items using OData

Created by Joshua Miller, Modified on Tue, 25 Mar at 5:17 PM by Joshua Miller

In some instances, specialized power query is required to retrieve beyond the first 1000 items from the Stratawise OData endpoint.

Instructions

Copy the script below, updating the Tenant ID and Module Name. (Lines 5 & 13)

let    EntitiesPerPage = 1000,     GetEntityCount = () =>         let Json  = Json.Document(Web.Contents("https://core.stratawise.com/odata/350/MA@POU",  [Query=[#"$count"="true"]])),             Count = Json[#"value"]         in  Count,     GetPage = (Index) =>         let Skip  = Text.From(Index * EntitiesPerPage),             Top   = Text.From(EntitiesPerPage),             Json  =  Json.Document(Web.Contents("https://core.stratawise.com/odata/350/MA@POU", [Query=[#"$skip"=Skip, #"$top"=Top]])),             Value = Json[#"value"]         in  Value,     EntityCount = List.Max({ EntitiesPerPage, GetEntityCount() }),     PageCount   = Number.RoundUp(EntityCount / EntitiesPerPage), //1,     PageIndices = { 0 .. PageCount - 1 },     Pages       = List.Transform(PageIndices, each GetPage(_)),     Entities    = List.Union(Pages),     Table       = Table.FromList(Entities, Splitter.SplitByNothing(), null, null, ExtraValues.Error) in     Table

 

  1. Connect to through the existing Odata connection provided through the export prompt in the module grid.

  2. Select Transform Data.

    Open image-20200803-211714.png

     

  3. Select Advanced Editor.

    Open image-20200803-211744.png

     

  4. Paste the updated script from above and select Done.

  5. Select the icon at the top of the data set to expand.

    Open image-20200803-211957.png

     

  6. Then OK.

    Open image-20200803-212028.png

     

  7. Select Advanced Editor again.

  8. Copy the resulting script to a text editor and replace “column1.“ with ““ (nothing).

  9. Paste the updated script in and validate the resulting columns appear correct.

     

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article