Azure Data Factory Data Flow concatenating groups of 3 rows into a single row

Bakhshpour, Daniel 41 Reputation points
2021-05-27T19:03:31.03+00:00

Hello, I am new to azure data factory and am having trouble combining multiple groups of rows into one row using a dataflow.

I have a test file that looks something like this

HEADER
ACT1 data1
ACT2 data2
ACT3 data3
ACT1 data4
ACT2 data5
ACT3 data6
FOOTER

Every three rows of data within this file refer to one row within a database. What I am trying to do is concatenate every group of three rows together so I can load it into a database. I would want it to look like:

HEADER
ACT1 data1ACT2 data2ACT3 data3
ACT1 data4ACT2 data5ACT3 data6
FOOTER

What would be the best way to do this?

Thanks

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

Accepted answer
  1. PRADEEPCHEEKATLA 90,641 Reputation points Moderator
    2021-05-28T12:15:51.357+00:00

    Hello @Bakhshpour, Daniel ,

    Welcome to the Microsoft Q&A platform.

    We can achieve this using Mapping data flow. You may checkout the below steps:

    Step 1: Add your data as source in Mapping data flow.

    100517-image.png

    Step 2: Add surrogate Key Transformation to get Incremental key column.

    100530-image.png

    Step 3: Add derived column transformation to generate new column with unique id for every 3 rows. So that we can utilize this column to group every three rows.

    100582-image.png

    Step 4: Add Aggregate Transformation and group By newKey Column as below and under aggregates a column with collect function as below.

    100489-image.png

    Step 5: Add derived column transformation to convert newHeader Column data to String.

    100559-image.png

    Step 6: take only NewHeader Column using Select Transformation with alias name as "Header" and finally load that data to Sink.

    100539-image.png

    Hope this helps. Do let us know if you any further queries.

    ---------------------------------------------------------------------------

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

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.