sam
sam

Reputation: 437

Azure Data Flow ( Data Flow) - First row field value as custom field to remaining rows

I am creating DataFlow in ADF. my requirement is to read first row one field value and make it as session id for rest of the rows. I looked into the expressions but didn't find much functions that will help on this.

ex: Source file in blob :---------------

 time               ,phone
 2020-01-31 10:00:00,1234567890
 2020-01-31 10:10:00,9876543219

 Target should be :-----------------

 SessionID          , time, Phone
 20200131100000,2020-01-31 10:00:00,1234567890
 20200131100000,2020-01-31 10:10:00,9876543219

SessionIID is a derived column. i need to read first row of time and remember that time and apply to all rows for sessionID.

How to read first row time value and keep it in global variable ? 

any inputs are appreciated. 

Upvotes: 1

Views: 3366

Answers (1)

Steve Johnson
Steve Johnson

Reputation: 8660

You can use Lookup activity in pipeline(check First row only option) and pass time value to Data Flow parameter. Then use Derived Column transform in Data Flow to add SessionID column.

Details:

  1. check First row only option in Lookup activity enter image description here

  2. use this expression to get your expected value:

@replace(replace(replace(activity('Lookup1').output.firstRow.time,'-',''),' ',''),':','')

enter image description here

3.pass value of this variable to parameter in Data Flow. enter image description here

4.add Session column in Data Flow. enter image description here

Upvotes: 1

Related Questions