Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
DSArkphire
Frequent Visitor

Web-based Cursor-Based Pagination issues

Hi I’ve been working on trying to use List.generate to create a paginated list from a api. My issue is that my api uses Cursor-Based Pagination. A single request will give me three sections “has-more” “offset” and “companies”.

2.png

If "has-more" is true, I need to make another request, using the "offset" value given to get the next page of company records, "companies" is the actual information I need.

 

3.png

 

I cant seem to figure out how to refer to the “has-more” and “offset” values within the list.generate step. No matter what I try list generate returns null values. 

 

4.png

 

5.png

 

1 ACCEPTED SOLUTION
ImkeF
Super User
Super User

Hi @DSArkphire 

you're not using the correct syntax to reference objects in Power Query / the M-language.

Try this:

 

Pagination = List.Generate( ()=>
	 Source, // Start value should be a record
	each [offset] <> 0 //  refers to the records field (your expression would always return true)
	each Json.Document(Web.Contents(<YourURLin””> & Text.From([offset])
)

Further reading on value types and how to reference them: https://docs.microsoft.com/en-us/powerquery-m/expressions-values-and-let-expression 

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

3 REPLIES 3
mark_steele
Regular Visitor

@DSArkphire - were you able to incorporate the solution provided by @ImkeF to resolve your issue? If so, could you please post the final/working code?

ImkeF
Super User
Super User

Hi @DSArkphire 

you're not using the correct syntax to reference objects in Power Query / the M-language.

Try this:

 

Pagination = List.Generate( ()=>
	 Source, // Start value should be a record
	each [offset] <> 0 //  refers to the records field (your expression would always return true)
	each Json.Document(Web.Contents(<YourURLin””> & Text.From([offset])
)

Further reading on value types and how to reference them: https://docs.microsoft.com/en-us/powerquery-m/expressions-values-and-let-expression 

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Thank you for your Help ImkeF and for explaining my problem, that's a big help. 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors