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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
v-nuoc-msft
Community Support
Community Support

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
v-nuoc-msft
Community Support
Community Support

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?

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Solution Authors