Look up values using in next lookup

Haider, Mustafa (Reigate) 25 Reputation points
2023-10-27T16:09:22.2733333+00:00

I have got 3 data sets one is Source and other is destination.

In first lookup I have got product family from PostgresSQL as a source of Lookup activity

In Second Lookup I need to pick up IDs against (product family i have selected in first lookup) from SQL Server database as a Lookup activity,

and it will be multiple product families not just first row.

in final copy activity i need productfamily id which i will get from second lookup and map in copyactivity.

How can i do that please?

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,958 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. QuantumCache 20,271 Reputation points
    2023-10-27T23:55:58.7+00:00

    Hello @Haider, Mustafa (Reigate)

    To achieve this, you can follow these steps:

    1. Add a Lookup activity to the pipeline and configure it to retrieve the product family from the PostgresSQL database.
    2. Add a ForEach activity to the pipeline and configure it to iterate over the output of the first Lookup activity.
    3. Inside the ForEach activity, add another Lookup activity and configure it to retrieve the IDs against the product family from the SQL Server database.
    4. Add a Copy activity to the pipeline and configure it to use the output of the second Lookup activity as the source and the destination dataset as the destination.
    5. Map the product family ID from the second Lookup activity to the destination dataset in the Copy activity.

    Here is an example of how you can configure the Lookup activities:

    For the first Lookup activity, set the source dataset to the PostgresSQL database and the query to retrieve the product family. Set the output to an array of strings.

    For the second Lookup activity, set the source dataset to the SQL Server database and the query to retrieve the IDs against the product family. Use a parameter to pass the product family from the ForEach activity to the second Lookup activity. Set the output to an array of objects.

    Here is an example of how you can configure the ForEach activity:

    1. Set the Items property to the output of the first Lookup activity.
    2. Inside the ForEach activity, add a Set Variable activity to set a variable to the current item in the loop.
    3. Add the second Lookup activity inside the ForEach activity and configure it to use the variable as a parameter.

    I hope this helps! Let me know if you have any further questions.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.