How to add data in new data column?

Hi All,

I have data table with 3 columns … want to Concatenate of column 1 and column2 in column3

Hi @Mandava_Naresh
Do u want to add a new column of sum SNO & Adm, or the Sum already exists previously?
If it was previously exists, then u just need to use Assign Activity and set row(“Sum”), with value Int32.Parse(row(“SNO”)) + Int32.Parse(row(“Adm”)).

Hey!

Try this:

In add data row

in the array of row mention like this:

{SNO,ADM,Concat}

Regards,
NaNi

Have to add only one row … First two should remain same

hi @Mandava_Naresh ,

Try using Add data column activity, instead of Add data row activity.

Yes

Above expression will works the same

Try it and let me know

Regards,
NaNi

Sum Column already exists … We just want to add column1+column2 in Sum

then u can try my way. Do it in for each row.

@Dharunya_Devi

@Felix_Effendi I was unable to add sum values in the data table

Hi @Mandava_Naresh

What you can do is

  1. Loop through each row of datatable using for each row,

  2. use an assign activity

row(“Sum”)= Cint(row(“SNO”).ToString)+Cint(row(“Adm”).ToString)

You will get the reqd results

Thanks & Regards,
Nived N

This one will show u the result in excel file.
Testing Project.zip (1.7 MB)

When the Sum of col1 and col2 is needed and you can control the datatype from the columns (as you have used Build Datatable you can change it to Int32) then you can do following

  • ensure thre columns are set to DataType: Int32
    Assign Activity
    YourDataTableVar.Columns(“Sum”).Expression = “[SNO] + [Adm]”

This will compute the sum and will do it without the need of a for each and will also be updated when values in other columns are changed

@NIVED_NAMBIAR … I was unable to add row(“sum”) value to data table

@ ppr … I was unable to add sum value in data table

@Felix_Effendi I want to write result in data table for string … Like how you did in excel for int

What error is it throwing?

@NIVED_NAMBIAR @Felix_Effendi

image

Hi @Mandava_Naresh , btw why the column name change to Concat?
Actually if it previosly has Sum column with String Type in datatable, then u just need to do “For Each Row” then use Assign Activity to assign row(“Sum”) with value (CInt(SNO) + CInt(ADM)).ToString.
No need to use Add Data Row activity anymore.

1 Like

Add Data Row activity adds a new row to the datatable. Since you are trying to update the value in a column, change your 3rd Assign activity in For Each Row to row(“Concat”) = SNO + ADM . This will update the Concat column value for that row.

1 Like