Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
Check it out now!Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more
Hi, I have a problem with my data source.
I am using an external API which only allows me to show 100-200 projects at once.
Unfortunately it will not show me the total pages. I hoped that this thread might be able to solve my problem
but I guess it does not because of this problem..
https://stackoverflow.com/questions/46904641/how-to-get-paginated-data-from-api-in-power-bi
So I always need to put a limit in my request in order to see projects. Is it possible
to create the query with a dynamic url? So basically it should increase my offset by 100 as long as my itemCount is 100 with a constant limit of 100 for example.
As soon as my itemCount goes below 100 it obviously reached my last page (we have around 10 in total).
I hope you guys get what I mean. So far I overcame this issue by hardcoding it and then merging all of my single requests to one. But this leads to me always having to make sure that I am not missing out a new page.
Thanks everyone!!
The API endpoint only delivers my project data as well as "itemCount", "limit" and "offset"
Solved! Go to Solution.
Please review the following blog to implement REST API pagination in Power Query.
https://medium.com/@marktiedemann/how-to-do-pagination-in-power-query-430460c17c78
Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.
@Thex You can use a Do Until loop in Power Automate for pagination if you can create a connection to your data source in Power Automate.
This loop will first get 100 records, then the next 100 records and so on until the largest number you have passed is met.
Hope this helps anybody facing a similar issue.
Please review the following blog to implement REST API pagination in Power Query.
https://medium.com/@marktiedemann/how-to-do-pagination-in-power-query-430460c17c78
Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.
Thanks! Even though the article did not help for my exact problem I could use it as a start to build my own functions. Since my API does not show my the maximum entries with one request I had to build a function which call itself until the point where my itemcount is below 100 which means that I reached my final page. After lots of trial and error it seems to work now. I'd like to share my code and get some feedback if I did everything right.
let
BaseUrl = "xx",
Token = "xxx",
Offset = 0,
GetJson = (Url) =>
let Options = [Headers=[ #"Authorization" = "Bearer " & Token ]],
RawData = Web.Contents(Url, Options),
Json = Json.Document(RawData)
in Json,
GetEntityCount = (x) =>
let Url = BaseUrl & Text.From(x),
Json = GetJson(Url),
Count = Json[#"itemCount"]
in Count,
GetPage = (x) =>
let Offset = Text.From(Offset + x),
Url = BaseUrl & Offset,
Json = GetJson(Url),
Value = Json[#"data"]
in Value,
CheckCount = (x as number) =>
let Indices =
if GetEntityCount(x) < 100
then x
else @CheckCount (x+100)
in Indices,
PageIndices = { 0 .. CheckCount(0)/100 },
Pages = List.Transform(PageIndices, each GetPage(_*100)),
Entities = List.Union(Pages),
Table = Table.FromList(Entities, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in
Table
So the return is the exact 1698 Projects which is up to the offset=1700 endpoint. I am just wondering why I am also getting all projects when I start with:
PageIndices = { 0 .. CheckCount(1500)/100 }
Shouldn't it just return 298 Projects then since I start with offset 1500?
Best regards!
Nobody here that might has an idea? Or is there not really a way to solve this?