How to create a new column in DataTable from the existing ones


I want to create a new column in Data table which should be derived from an existing column.
Any leads would be appreciated.

Attached the Data table

Values highlighted in yellow needs to be a new columnsCapture

Thanks in Advance.


welcome to uipath community @Vasudha_Joshi
–where mention the datatable name and column name we want to place the new value
the steps included are
–use a excel application scope and pass the file path as input
–use a read range activity and get the output with a variable of type datatable named outdt
–use add datacolumn activity and mention the above variable as datatable and mention the columnname we want
–now use a for each row loop and pass the above datatable outdt as input
–inside the loop use a assign activity like this
row(“yournewcolumnname”) = Split(row(“Item Text”).ToString,"-")(1).ToString.Trim
–now that value will get added to the new datacolumn

hope this would help you

Cheers @Vasudha_Joshi


Use add data Column activity
then use for each row
in that assign row(“NewColName”)=row(“Item Text”).tostring.split("-"c)(1)

hello @Vasudha_Joshi

create a new table using build data table activity with column names you want.
then loop through the above data by reading it in an other datatable.

inside loop use add row activity, add all the values into the new datatable , write it back into excel will solve your problem.

Before add row activity you need to split the string in the last column which you highlighted in the excel.


If you feel the data table is hard to understand, do the following steps

  1. read the entire excel and store in a datatable
  2. Then use for each row to iterate through the data rows and inside that , use the same excel application scope and write cell activity to write in a new data into the new column as in the screenshot


This will write the value in the excel directly :slight_smile:
Hope this helps @Vasudha_Joshi

Thanks guys! Its working.

1 Like

Cheers @Vasudha_Joshi

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