Copying Substring of a column to another column?

Problem:
I have a datatable column where I would need a specific data(substring) from it. The specific data would then be placed in another datatable column.

Given:
image
How can I create a datatable column(ID) like this? Without using loops or formulas in excel where I would be placing the datatable?

Please advise.

Thanks!

1 Like

hii @Michael_de_Borja

try this,
Read Range Excel sheet —> dt (Datatable)
assign activity,

where

  1. dt: —> your whole datatable with column (Account, ID)
  2. New_dt: —> new datatable with column ID only.
1 Like

Thanks for your reply!
But what I need is both the columns.
I need the substring of Account column to be in ID column, as shown in the image.

Thanks

1 Like

@Michael_de_Borja

Use Read Range for the existing excel.

Add DataColumn with Column Name as ID

then use the below query

DataTableVariable2 = (From x In DataTableVariable1.AsEnumerable()
Select DataTableVariable1.Clone.Rows.Add({x(“Account”),convert.ToString(x(“Account”)).split("-"c)(1).Substring(0,3)})).copytodatatable

you can use DataTableVariable2 as u require

3 Likes

Thank you!

1 Like

Quick question! How do I attach the newly created column, directly to the same datatable?
Without the use of loops? :smiley: