Adding a new column to a datatable which concatenates other columns data


I have a Data table in UiPath where it has a few columns each containing data. I want to add another column to this Data table and concatenate some of the fields to make a unique string. I’m quite lost with what steps I should be taking to achieve the result. An example of the Data table and the outcome that I wish to receive are below.

Example of Datatable before
Col1 Col2 Col3 Col4 Col5
AT 125 08 STA DA
AT 536 07 VBA AR

Example of Datatable after
Col1 Col2 Col3 Col4 Col5 Col6
AT 125 08 STA DA 12508STADA
AT 536 07 VBA AR 53607VBAAR

I have been able to do the following:
Use a “Add Data Column” activity to make a new blank row
Use a “For Each Row” activity with an assign activity inside to assign the value to the new column with the column values that i wish to concatenate.

My question now is there any better way to achieve this result?

1 Like

Buddy @Nicholas_Doss
Here is your xaml, buddy this would help you buddy, it worked as you expect (13.5 KB)

Kindly let know whether this works or not buddy…

Hi @Nicholas_Doss

I have created workflow based on requirement please check and let me know. (19.5 KB)

before run that workflow please delete col5, col6 form Sheet1 “Test.xlsx” file.

You don’t need an Excel Application Scope activity to achieve this, you might just use Microsoft dotnet Language Integrated Query (LINQ) and use the assign activity to directly concat the two (or more!) fields within your ForEach Row activity:

ForEach row in DataTable

    row("col5") = String.Concat(row.ItemArray.Take(2))

    row("col6") = String.Concat(row.ItemArray.Skip(2).Take(2))


Did that work for your scenario buddy @Nicholas_Doss

Hi @Palaniyappan. This does work however i am using 1 million lines plus so excel is not favourable.

I have ended up using a for each row and using a query similar to the one that @iRon has suggested.

Thank you for your help everyone

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.