none
Specify Order for Items in Foreach Activity RRS feed

  • Question

    1. Is it possible to specify the order for iteration in the Foreach activity based on some available attributes inside items?
    2. Is the order of iteration preserved in Foreach activity if we order the results from the source, let's say SQL Server'

    Thank you


    Sohi

    Thursday, April 18, 2019 7:34 PM

Answers

  • Hi,

    Foreach activity provides a property 'isSequential' for you to configure whether the iteration is executed in sequential or in parallel. If you set isSequential is true, the order of iteration would be preserved. For specifying the order for iteration, there is no native way for it. You need to preprocess the source iterations as the order you want, then pass it to Foreach activity to run. Useful link: https://docs.microsoft.com/en-us/azure/data-factory/control-flow-for-each-activity#type-properties

    Hope this helps.

    • Marked as answer by Sohi420 Friday, April 19, 2019 5:21 PM
    Friday, April 19, 2019 1:32 AM
  • Hi,

    yes.You can order the iteration based on the order results of any activity.

    PFB the example for the same:

    I have a lookup activity which is basically a select query:

    Select ExtractDt  from dbo.extractdate where ProcessedStatus <>'Processed'
    and ApplicationNm= @PipeLineNm
    Order by ExtractDt

    the output which is provided to the ForEach activity as an input as shown above.

    The extractdates are in Ascending order since the output is Order by ExtractDt.

    Hope this answers your query.

    • Marked as answer by Sohi420 Friday, April 19, 2019 5:21 PM
    Friday, April 19, 2019 6:02 AM

All replies

  • Hi,

    Foreach activity provides a property 'isSequential' for you to configure whether the iteration is executed in sequential or in parallel. If you set isSequential is true, the order of iteration would be preserved. For specifying the order for iteration, there is no native way for it. You need to preprocess the source iterations as the order you want, then pass it to Foreach activity to run. Useful link: https://docs.microsoft.com/en-us/azure/data-factory/control-flow-for-each-activity#type-properties

    Hope this helps.

    • Marked as answer by Sohi420 Friday, April 19, 2019 5:21 PM
    Friday, April 19, 2019 1:32 AM
  • Hi,

    yes.You can order the iteration based on the order results of any activity.

    PFB the example for the same:

    I have a lookup activity which is basically a select query:

    Select ExtractDt  from dbo.extractdate where ProcessedStatus <>'Processed'
    and ApplicationNm= @PipeLineNm
    Order by ExtractDt

    the output which is provided to the ForEach activity as an input as shown above.

    The extractdates are in Ascending order since the output is Order by ExtractDt.

    Hope this answers your query.

    • Marked as answer by Sohi420 Friday, April 19, 2019 5:21 PM
    Friday, April 19, 2019 6:02 AM