Hi, From where this datatable is populated, there itself you can try to populate the third column as well. Sorry if my understanding is not correct here. Let us know where you are getting the datatable dt1.
If it is from DB then we can achieve this using query in the database itself.
If it is from Excel, then append the excel before reading it for the third column then read it.
Here is the solution:
Use Invoke method activity, assume my DT column names are ‘Entity’ and ‘AccountId’.
TargetObject: DT.Columns.Add(“FORMULA”, GetType(String), “[Entity]+[AccountId]”)
MethodName: SetOrdinal (Need to pass the ordinal value using argument)
Where FORMULA- my new column name(Concatenated columns)
SetOrdinal- new column ordinal position
Hi @VasuNaidu Thank you so much for taking the time sharing your solution. I was able to implement this.
P.S. Sorry I deleted my previous entry because I implemented it with a loop, but Invoke Method was so much better(performance wise).
Hi vasu…your solution worked if I build a data table set a variable and pass it…but if I read from excel store it in a data table and pass that…the columns are getting added …for example columnA:12001 columnB:1 my desired output is column C:120011 but IAM getting columnC:12002…please help…
In case someone is still interested. There is an easier way to achieve this.
Create a new variable “FORMULA” of type “System.Data.DataColumn” and use assign activity.
Formula = DT.Columns.Add(“FORMULA”, GetType(String), “[Entity]+[AccountId]”)
Actually, the DataColumn’s ColumnName or Caption are not changed but the write range activity seems to rely on DataColumn’s ToString method to ouput its header and this will take first the DataColumn’s Expression property if defined.
If you use the Output Data Table you’ll see different headers.
Hello, sorry, I don’t understand your question. What are trying to do?
“How to concatenate two columns in datatable without looping and keep concatinated data in new column?” is the original question. Are you asking to apply the concatenation to an already existing column?
With an Assign activity, with DT as your DataTable and "Formula" as your DataColumn’s name. If you don’t have the DataColumn’s name, you might give its index as Integer instead. Entity and AccountId are the concatenated column names.
FORMULA is Column Variable I understand.
what is Formula? is that pointing to same Column Name?
ALso I needed a space in between the Entity and AccountId. How to achieve this?