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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Leggies
Frequent Visitor

How to setup the pagination next_page for all pages

Hi,

I'm trying to up the data from Zendesk through PowerBI, but i only get the first results. How do i setup the pagination in Power Query to get all results? I've tried with List.Generate, but i'm unable to succeed so far. Do you got a solution?

The Query tells me what the next_page and last_page is. 

The query is

let
Source = Json.Document(Web.Contents("https://xxxxxxxx.zendesk.com/api/v2/tickets.json?", [Headers=[Authorization="Basic ZGlXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"]])),
#"Converted to Table" = Table.FromRecords({Source})
in
#"Converted to Table"

Leggies_0-1629715784074.png

 




6 REPLIES 6
v-xiaotang
Community Support
Community Support

Hi @Leggies 

did you try to click on expand button?

vxiaotang_0-1629874265805.png

 

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

@v-xiaotang i've tried, but it only gives the first 100 results. I'm trying to make a loop, but nothing works so far.

selimovd
Super User
Super User

Hey @Leggies ,

 

you have to loop through multiple API call.

Search in the community, that topic appeared many times. Also check the following video:

Pagination and DO/WHILE in Power BI / Power Query - YouTube

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

Hi @selimovd 

I tried, but its not working. I get the error "We cannot convert a value of type List to type Number." This is the Query:

let
Page = {1,1000},
Source = Json.Document(Web.Contents("https://xxxxxxx.zendesk.com/api/v2/tickets.json?page="&Number.ToText(Page), [Headers=[Authorization="Basic ZGlxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"]])),
#"Converted to Table" = Table.FromRecords({Source}),

List = List.Generate(() =>
[Result= try GetData(1) otherwise null, Page = 1],
each [Result] <> null,
each [Result = try GetData([Page]+1) otherwise null, Page =[Page]+1],
each [Result])

in
#"Converted to Table"

amitchandak
Super User
Super User

@Leggies , do you need what is discussed here

 

https://medium.com/@marktiedemann/how-to-do-pagination-in-power-query-430460c17c78

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak ,

I've tried your solution, but i get the following error:

Expression.Error: The field '@odata.count' of the record wasn't found.
Details:
tickets=[List]
next_page=https://xxxxxxx.zendesk.com/api/v2/tickets.json?page=2
previous_page=
count=9758


Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.