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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Saadii_360o
Helper I
Helper I

Power BI Pagination & Looping using List.Generate

Hi everyone. I am posting again because could'nt find my solution.
ISSUE:

URL: https://vcc-na8.8x8.com/api/stats/agents//agents/{agent-id}/activities?n={offset}

As you can see in above URL that I have to add agent id every single time and this API provides 50 rows per request.
NOTE: API does not provide any information on count etc
With help of @mahoneypat  I was able to create a function which allows me to extract all id's along with the pagination, PFB,

(id as text)=>

let

Source =

List.Generate( ()=>[result = try Xml.Tables(Web.Contents("https://vcc-na8.8x8.com",[RelativePath="/api/stats/agents/"&(id)&"/activities?n=1"])) otherwise null, n=1],


each [result]<> null,

 

each [result = try Xml.Tables(Web.Contents("https://vcc-na8.8x8.com",[RelativePath="/api/stats/agents/"&(id)&"/activities?n="&Number.ToText([n]+50)])) otherwise null, n=[n]+50],

each [result])

in

Source


Issue with the function:
1.Function is providing infinite tables. it is on constant loop I think.

Saadii_360o_0-1646813547526.png

 


2. When i try to invoke this function with Agent id's from new table it only formats the table with the first ID which is empty and provides null values.

Saadii_360o_1-1646813583191.png


3. It is on constant load. does'nt do anything.

Saadii_360o_2-1646813621117.png


PFB the link to my video which i have created for the better understanding. It will save your time to provide the solution.

Link: https://drive.google.com/file/d/1xbASl1EaziV3qp1ptZlzCtA-fbXnbJ3R/view?usp=sharing

API Documentation: https://support.8x8.com/cloud-contact-center/virtual-contact-center/developers/8x8-contact-center-st...

Requirment: Looking for a function which provides all the id's with all the rows(Pagination).


Really looking forward for someone's help.

Best,
Saad.




1 REPLY 1
v-jingzhang
Community Support
Community Support

Hi @Saadii_360o 

 

The problem is that it's difficult to know how many activities every agent id does have, so it's not sure when it should end the loop. Maybe you can consider giving a large enough number as the loop time (for example 10 times) that every agent id will run this loop 10 times. After that, add a step to remove rows having empty tables. But if some agents have more activities than 500, this will lose records whose offset is larger than 500. 

 

Best Regards,
Community Support Team _ Jing

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors