Retrieving one column from a DataTable

Hi there,

Say if I have a datatable called Identity:
Name Country
Amy UK
Ben UK
Carey USA

Q1) I am trying to retrieve the Name column from Identity datatable and add this column to a new datatable. I have tried to assign a variable called Name (datacolumn type) to Identity.column(0) but it is not working and saying that column 0 cannot be found.

Q2) Also, I am wondering how I can build another datatable using the Name column.
Say I have successfully retrieved the Name column. I want to build a datatable called Hobby:
Name Hobby

what I would like to do is assign the value for Hobby column one by one. Is using for loop the method to do it?

Thank you.

Hi @vanicwl

If your datatable is dtTable and the output is dtTable2 (with name column)

in Assign activity

dtTable2 = dtTable.defaultview.totable(false,β€œname”)

Now dtTable2 will contain only name column

Use add data column activity to add the new column called Hobby (pass dtTable2 datatable)

If the hobby column has same value for every row then you can use default value on add data column activity property.

1 Like

see my previous solution