Home > Back-end >  How to grab a cell value and write it as a new column. Excel to SQL copy activity Azure Data Factory
How to grab a cell value and write it as a new column. Excel to SQL copy activity Azure Data Factory

Time:01-17

I have a copy activity pipeline that simply copies cells A6:C9 into sql table. enter image description here

enter image description here

However, now I need to grab the value in a cell A3 (date) and write it as a new column in sql table.

enter image description here

How can I achieve that? Do I need to use another copy activity? Or it can be done in a single one?

UPDATE: value A3:A3 in Lookup activity.

enter image description here

CodePudding user response:

You may fetch the desired value with a Lookup activity, and then add it to the Copy Data activity as an additional column. Please see the example below.

Start by creating a range parameter on your Excel dataset, so you may provide it dynamically in the pipeline:

Parameterizing Excel dataset

Make sure the Range parameter is added in the Connection tab as well.

enter image description here

Next, create a pipeline with a Lookup activity, followed by a Copy Data activity. The lookup activity should provide the range for the cell you want to capture (in my case, B1)

Lookup activity

Finally, in the Copy Data activity, insert an additional column and provide it the Lookup activity output.

Copy Data activity

The expression I used is @activity('Lookup1').output.firstRow.Prop_0. This will add a column called Date with the value in B1, for every row.

  • Related