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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
fheller98
Helper I
Helper I

For-Loop

Hello all,

We want to pull data from an API using an empty query - unfortunately the API only provides the data per employee, but we want to have a large table with all employee data, so we are currently thinking about how to handle this.

Example:

User ID:
sajnsonsa34sesr
woefefmwe5452
psdmcsado2353

Empty query:
let
Source = Json.Document(Web.Contents("https://api.XXXXXX.com/api/v2/company/[USER-ID]" & ....

Is it possible to build a for-loop to pull out all the data for individual employees based on the user IDs one by one? Or do we have to use python or something like this?

 

---------------------------------------------------------

 

@v-easonf-msft do you maybe have an idea?

2 REPLIES 2
fheller98
Helper I
Helper I

Hey @amitchandak 

thanks for your fast answer. I think it is not going to help because there is one query which get divided into smaller queries, if i get it right.

We need a loop for replacing some part of the url, then trigger again, then replacing etc.
Do you think this would work too?

let
Source = Json.Document(Web.Contents("https://api.XXXXX.com/api/v2/employees/" & employeeId & "/timetracking", [Headers=[Authorization = Authentification]])),
data = Source[data],
#"Converted to Table" = Table.FromList(data, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"id", "employeeId", "projectId", "requestDate", "startTime", "endTime", "totalTimeInMinutes", "breakTimeInMinutes", "comment", "status", "categories"}, {"Column1.id", "Column1.employeeId", "Column1.projectId", "Column1.requestDate", "Column1.startTime", "Column1.endTime", "Column1.totalTimeInMinutes", "Column1.breakTimeInMinutes", "Column1.comment", "Column1.status", "Column1.categories"})
in
#"Expanded Column1"

See the example and highlighted part. And we want to get the data for all employees in one query by replacing the employeeID again and again...

Thanks
Finn

amitchandak
Super User
Super User

@fheller98 , refer if this similar blog can help

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

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.