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

Join us at FabCon Vienna from September 15-18, 2025, for the ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM. Get registered

Reply
RajuArge
New Member

How to collect data from different sources dynamically using foreach loop activity

Hi Team,

 

I would like to collect data from different data sources and store data in dataset dynamically using Foreach activity.
Once I collect the data from different sources via Foreach activity, i would like to perform join or union based on client data and configurations(json).

Is it possible to create datasets dynamically?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @RajuArge 

 

You can dynamically create datasets and perform join or merge operations using ForEach activities. The general steps are as follows:

 

Create a ForEach activity that traverses an array containing information about the data sources.

 

Inside the ForEach loop, you can use activities such as Copy Data to extract data from each source and store it in a temporary dataset.

 

At the end of the ForEach loop, use the Data Flow activity to join the two datasets.

 

Store the joined dataset in the target location.

 

ForEach activity - Microsoft Fabric | Microsoft Learn

 

Regards,

Nono Chen

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

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @RajuArge 

 

You can dynamically create datasets and perform join or merge operations using ForEach activities. The general steps are as follows:

 

Create a ForEach activity that traverses an array containing information about the data sources.

 

Inside the ForEach loop, you can use activities such as Copy Data to extract data from each source and store it in a temporary dataset.

 

At the end of the ForEach loop, use the Data Flow activity to join the two datasets.

 

Store the joined dataset in the target location.

 

ForEach activity - Microsoft Fabric | Microsoft Learn

 

Regards,

Nono Chen

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

Hi Nono Chen,

Thank you so much for quick reply. API is also one of my data source so , how we pull data from API efficiently iteratively. Can you please help me out with this?

Anonymous
Not applicable

Hi @RajuArge 

 

If you have multiple APIs to deal with, you may want to consider the following suggestions:

 

Create a configuration file that stores all API information in a json file or other format. Example:

 

{
  "apis": [
    {
      "name": "API 1",
      "url": "https://api.example1.com/data",
      "method": "GET",
      "auth": "Bearer YOUR_API_KEY"
    },
    {
      "name": "API 2",
      "url": "https://api.example2.com/data",
      "method": "GET",
      "auth": "Bearer YOUR_API_KEY"
    }
  ]
}

 

Add a Foreach activity to iterate through the list of APIs. Transfer the list of APIs as a collection of inputs to the Foreach activity.

 

Add a Web activity inside Foreach to extract the URL of the current API with dynamic content, for example:

 

@{item().url}

 

Select the request method, GET.

 

@{item().method}

 

Store the response data for each API into a temporary dataset.

 

Data from multiple APIs can be merged in subsequent steps using the Data Flow activity.

 

Regards,

Nono Chen

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

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June FBC25 Carousel

Fabric Monthly Update - June 2025

Check out the June 2025 Fabric update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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