How to replace a column/row value in datatable in Uipath (based on some condition) without using for each row

Hi All,

I have a dataTable with 3 columns Column1, Column2 and Column3 with 100 rows.
Column1 Column2 Column3
123 hello GoodMorning
765 heloon GoodNight
134 hey GoodEvening
123 hi GoodEvening
I wanted to replace the values of all rows in Column1 based on some condition.
Example : Replace the value with new value “1234” if the existing value is “123”
Or Replace the value with new value “1234” if the eixsting value is >120

Use a assign activity like this if we know which column values we want to replace
dt = dt.AsEnumerable().Where(Function(a) a.Field(of string)(“yourcolumnname”).ToString.Replace(“your old value”,” your new value”).ToString).CopyToDatatable()



But this is giving me an error in UiPath studio :

Option Strict On disallows implicit conversions from 'String' to 'Boolean'.


Follow the steps belo:-

  1. Take one read range output as-> dt_out
  2. Take one Assign activity Create a int veriable->Counter
  1. Take one for each row in Data table → pass the dt_out
  2. Take one if condition. Mention the condition like this:

In Then Part :

Take one Assign Activity - Create string variable DataReplace

DataReplace = CurrentRow("ColumnName").ToString.Replace("123","1234").ToString


Take one write cell activity…

Pass the value as DataReplace in the range mention


Take one Assign activity


In Else part:- Take one Continue activity

Try this and let me know


Thanks for the response. But my question is to perform modification with out for loop.

in the case of 100 rows, we don’t see any blocker for using for each row activity.

For an overview of the different options we do have find the following blog link:
How to Update Data Column Values of a Data Table | Community Blog

when all rules are fixed and defined, then we can give more details on an alternate solution approach

as the Where operator is expecting a boolean return from the Lambda function there will be a missmatch with the returned string from the replace method. Therefore we do get a validation error.

Also we do need a return value from every step we do formulate within the LINQ. That’s the reason why some constructs e.g. row(ColNameOrIndex) = “ABC” will not work within the assign activity.