Forum Discussion

jkrumb's avatar
jkrumb
Regular Visitor
1 year ago
Solved

Fabric pipeline - ForEach Variable data to Warehouse

Hello everyone,
As you can see in the image, inside the red box on the right, these are the types of values I would like to insert into the data warehouse. I retrieve these values from a ForEach loop containing a variable. As you can guess, I would like to insert all the data from the variable into the data warehouse.

 

 

 

Thank's you for your help.

 

JK

 

  • Anonymous's avatar
    Anonymous
    1 year ago

    Hello jkrumb ,

    Thank you for reaching out to Microsoft fabric community form.

     

    To insert values from a ForEach loop into a Data Warehouse within Microsoft Fabric, you can use the ForEach activity to iterate over your array or list of items. Inside the loop, add a Copy Data or Stored Procedure activity that handles the insertion logic.

    You can reference each item dynamically using the @item().propertyName expression, which allows you to pass values from the current iteration into your sink (e.g., a Warehouse table).

    For reliable execution, especially when dealing with insertions or variables, it's recommended to set the loop mode to sequential, as variables and some operations are not thread-safe in parallel mode. If you require more advanced logic (e.g., dynamic SQL), consider using the Script activity within the loop.

     

    For more details, refer to the official Microsoft Fabric documentation on ForEach activity, which outlines usage patterns and best practices.

     

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

     

    Thankyou.

6 Replies

  • Hi jkrumb ,

     

    To insert values from a ForEach loop into your Data Warehouse, you can follow this approach:

    1. Inside the ForEach activity, use a Copy Data activity
    2. Set the source as the variable or dataset you're iterating over
    3. Set the sink (destination) to your Data Warehouse table
    4. Make sure the schema mapping is correctly defined so each iteration inserts the expected values

    If your variable is an array of objects, each iteration will handle one object. You can also use a Script activity if you need more control over the insert logic (like using dynamic SQL)

    Let me know if you need help with the exact pipeline setup

    If my response resolved your query, kindly mark it as the Accepted Solution to assist others. Additionally, I would be grateful for a 'Kudos' if you found my response helpful.

    • jkrumb's avatar
      jkrumb
      Regular Visitor

      Thank's,

       

      My value var2 :

      {
        "id": @{json(item())?['id']},
        "name": @{json(item())?['name']},
        "refreshType": @{first(activity('Web1').output.value)?['refreshType']},
        "endTime": @{first(activity('Web1').output.value)?['endTime']},
        "status": @{first(activity('Web1').output.value)?['status']}
      }
      How configure source copy data ?

       

       

      Thank's you ?

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hello jkrumb ,

    Thank you for reaching out to Microsoft fabric community form.

     

    To insert values from a ForEach loop into a Data Warehouse within Microsoft Fabric, you can use the ForEach activity to iterate over your array or list of items. Inside the loop, add a Copy Data or Stored Procedure activity that handles the insertion logic.

    You can reference each item dynamically using the @item().propertyName expression, which allows you to pass values from the current iteration into your sink (e.g., a Warehouse table).

    For reliable execution, especially when dealing with insertions or variables, it's recommended to set the loop mode to sequential, as variables and some operations are not thread-safe in parallel mode. If you require more advanced logic (e.g., dynamic SQL), consider using the Script activity within the loop.

     

    For more details, refer to the official Microsoft Fabric documentation on ForEach activity, which outlines usage patterns and best practices.

     

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

     

    Thankyou.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi jkrumb ,

      I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.


      Thank you.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi @jkrumb ,

    I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.


    Thank you.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi jkrumb ,

     

    May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

     

    Thank you.