How to add data to particular column?

@cybzom

Will try it tomorrow and let you know.

1 Like

Please do sir thanks

Fine
Sorry for the delayed response
Was help up with some meetings

Let’s do like this
—suppose your datatable is named dt1
And output datatable is named dt2
—now use a FOR EACH ROW loop and pass the variable dt1 as input
—inside the loop use a IF condition like this
NOT dt2.Columns.Indexof(row(“location”).ToString).Equals(-1)

This condition will check first whether that location column is there in the output datatable or not with index value
If true means dt2 has that column so goes for THEN part or if not goes to ELSE part where we can use ADD DATACOLUMN ACTIVITY and mention the ColumnName as row(“location”).ToString and in datatable mention as dt2
So that it will create a column of that name
Next to this loop

—use a assign activity like this
dt_sample = dt1.Asenumerable().Groupby(Function(a) a.Field(of string)(“location”)).Select(Function (b) b.First()).CopyToDatatable()
Where dt_sample is a variable of type datatable with default value as new system.data.datatable

—then another assign activity like this
arr_locations = dt_sample.AsEnumerable().Select(Function (a) a.Field(of string)(“location”).ToString).ToArray()

—use a FOR EACH activity and pass the variable arr_locations as input and
—inside that loop use a FOR EACH ROW loop and mention dt1 as input
—now use a IF condition and mention like this
item.ToString.Equals(row(“location”).ToString)
If true it will go to THEN part where
—use a add Datarow activity and mention the Datarow as dt2.NewRows and in datatable mention as dt2
—then we can use a assign activity like this
dt2.Rows(dt2.Rows.Count-1)(item.ToString) = row(“Pay”).ToString

Cheers @cybzom

2 Likes

Thanks na :slight_smile:

It’s working perfectly but, it’s not adding the name and location

It should be like

Name. Location. Location 1 location 2 etc

1 Like

That’s great
We need to create a datatable withName column alone using build datatable activity so that new columns can be added and Name column will be there

Kindly let know for any queries or clarification
Cheers @cybzom

You mean to set col2 and col3 of row2 from null to some meaningful data or what?