Add Column in data table with modified value

Hiii, I’m New to UiPath studio, we Use UiPath Community edition 2023.4
design job for read excel file and copy specific column in another excel file .now I want add column in new excel or datatable ,and column value is old datatable column value plus(+)zero(0).
example:HRA Arr=datatable1.columns(HRA)+0
in above HRA Arr is new column name which want to add datatable2,and HRA is old datatable column.
Please guide me .

Hi @ashwini.mali - If you want to add new column in data table, use activity Add Data Column

  • Give column name and Data table name to which you want to add the column

Picture1

thank you for your reply, please tell me how to call the old data table column with value in the new data table. and multiple value I mean number of row @ushu

@ashwini.mali - Trying to understand better, create a new column HRA ARR in new data table assume DT1, now you want to copy the data in the column value named HRA in the old data table assume DT to HRA ARR column. right?? correct me if I am wrong

yes correct ,and dt column HRA+0 in dt1 columns that is HRA Arr @ushu

@ashwini.mali - Please check the attached workflow and let me know if it helps or need any changes

SampleWorkflow.zip (3.4 KB)

Thank you @ushu ,try above workflow but in my case getting error in assign activity ,Kindly check attached screen shot


help me to resolve issue

@ashwini.mali - Make sure you define the Index as a variable. Go to variables panel and define the variable with type Int. You can rename the variable you want

Now give that variable in the For Each Row in Data Table output

Thank you so much for solution @ushu ,error is resolved but Blank column is add


@ushu Kindly check screen shot

@ashwini.mali - You don’t want that blank column to add in your excel or is the data missing for that column . Please confirm

@ushu Check column is not blank .in HRA column in old datatable contain values,
can we add column name instead of index number
CInt(CurrentRow(HRA).ToString)+0
HRA is column name

@ashwini.mali - Yes, you can do that. If you give index or column name it should get the value from the data table and store in a variable.

@ushu I’m try with column name but same excel is create ,Blank column ,which is the right way for write
CInt(CurrentRow(“HRA”).ToString)+0
or
CInt(CurrentRow(HRA).ToString)+0
but when i try to write column name without qoute(“”) getting error

@ashwini.mali - The above one is the right way. Once you assign a value, keep some message box and check the res

Ex in your assign activity, DT1.Rows(Index).Item(1) = CInt(CurrentRow("HRA").ToString)+0

Within the message box activity say, DT1.Rows(Index).Item(1).ToString. This way you know the data has properly inserted or no (OR)

You can also use Output Data Table activity outside the For Each Row in Data Table to print the data table data and check whether it has the data inserted

Hello ,anyone-have any idea about my issue

Try above ,value is push but not store or save in data column


column
@ushu kindly check ss

@ashwini.mali - can we connect on this, if not possible can you please share your workflow

@ushu Thank You for your support Please check Attached workflow file ,
Main.zip (3.5 KB)

@ashwini.mali - One of my observation was within the For Each Row in Data Table activity, first assign activity you were using is like

newDatatable.Rows(Index).Item(1) = CInt(CurrentRow("HRA").ToString)+0

Are you sure it is Item(1), here 1 represents first column. Let’s say if new column got added at position 5 in the new data table then the above exp should be as

newDatatable.Rows(Index).Item(4) = CInt(CurrentRow("HRA").ToString)+0

FYI - Column index always starts with 0, hence it is Item(4)

2nd Observation

You are using another assign activity within the For Each Row, you used same exp in the left side. This exp actually replaces the existing data present in newDatatable.Rows(Index).Item(1), with the resultant value coming from the exp CInt(CurrentRow("Other Allowance").ToString)+0+0+0 (right side)

newDatatable.Rows(Index).Item(1) = CInt(CurrentRow("Other Allowance").ToString)+0+0+0

This could be reason, you are getting empty values . Please print the newdatatable after second assign activity using Output DataTable activity and check the output

@ushu Thank you so much for support and resolved my issue ,