New column in a data table by concatenating to existing columns

Hi,

I have 1 DT. With the below columns :

SlNo,TRANSACTION_ID,PNR_NO,CLIENT TRANSACTION ID,BOOKING_AMOUNT,PG NAME,CLASS,TRANSACTION_DATE,USER_ID,PRINCIPAL_USER_ID, AMC_Charge(Including GST).

I want to introduce a new Column(CLIENT TRANSACTION ID + BOOKING_AMOUNT) in the data table. This is equivalent to =CONCATENATE(CLIENT TRANSACTION ID, BOOKING_AMOUNT) in excel.

I am new to Uipath. Please help.

@shrayud
image

Pass the new column name and Datatable name

Hi,

I am aware of this activity. Can you explain the working with this? I mean how to concatenate the columns?

@shrayud Create new data table DT2 and use DT2=DT1.clone
Then add a new column to DT2 and then iterate through DT1 and add a data row to add all the values from DT1 with new column values

Hi , Tried the same. PFA .xaml file.

Please know that this is taking lot of time to execute. I have files of 18K rows. Can you please optimise it?

test_concatenate.xaml (7.1 KB)

@shrayud

have a look here, especially for the second part. It has the potential to avoid a for each run for setting the value for the newly added datacolumn:

so in your case:

  • Add datacolumn activty
  • assign activity
    #leftside: yourDataTableVar.Columns(ColNameOrIndex).Expression
    #right side: “CLIENT TRANSACTION ID + BOOKING_AMOUNT”
2 Likes

Hi peter,

I am new in UiPath. It would help if you can be a bit more descriptive. Thanks :slight_smile:

Hi @shrayud,

Try using the Add Data Column activity directly.

For this, you need to read your table from excel into a DT.
Use Add Data Column activity:
Specify properties column name, datatable name and object type(value type)
Now the data column is added.

To perform your action on this column, use for each row
For each row in Datatable
row.Item("") = “Your Value”

After the for loop, write range and don’t forget to add headers while writing it to excel.

just go through the link for more details.
Your flow could look similar like this:

grafik

in your case:

  • Add datacolumn activty
  • assign activity
    #leftside: yourDataTableVar.Columns(ColNameOrIndex).Expression
    #right side: “CLIENT TRANSACTION ID + BOOKING_AMOUNT”
1 Like

image

  1. Add column with name TRAN_ID_BOOKING_AMOUNT
  2. Then use assign with below expression
DailyBookingDT.Columns("TRAN_ID_BOOKING_AMOUNT").Expression = "[CLIENT TRANSACTION ID] + BOOKING_AMOUNT"

Please find attached the sample flow for reference.

test_concatenate (1).xaml (5.9 KB)

1 Like

Hi @shrayud

You can try invoke method for concatenating columns

check link

Regards,

Nived N

Happy Automation

You need to refer to the same column name in your Assign activity as in the Add Data Column activity:

image

image

Also, if your column name contains space(s), you need to surround it with square brackets.

So you Assign should look like this:

DailyBookingDT.Columns("TRAN_ID_BOOKING_AMOUNT").Expression = "[CLIENT TRANSACTION ID] + BOOKING_AMOUNT"
2 Likes

You forgot square brackets:

image

image

1 Like

Updated in original comment… Thanks

1 Like

This works fine. Thanks a lot everyone for helping out. :slight_smile:

Just curious what is the logic of “[ client transaction id] > square brackets” ?

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