Mutliple two columns of the same datatable and assign the result to new column of same table

Error ERROR Validation Error Compiler error(s) encountered processing expression “dtFinalData.AsEnumerable.ToList().ForEach(Function(r) r.SetField(“NewColumnName”), r.Field(“ColumnName1”)*r.Field(“ColumnName2”))”.
‘r’ is not declared. It may be inaccessible due to its protection level.
‘r’ is not declared. It may be inaccessible due to its protection level. Sequence.xaml

@kalpana_venkutusamy

You can use like this

Use a add data column activity and add a datacolumn of type double …I see you are multiplying two columns

Use assign as below

dt.Columns("NewColumnName").Expression = "[Column1] * [Column2]"

Or try using the below in invoke code…makes ure you add dt as in/out variable

dt.AsEnumerable().ToList().ForEach(Sub(r) r("NewColumn") = CDbl(r("Column1")) * CDbl(r("Column2")))

cheers

Thank you. Your solution resolved the issue.

  1. Added new column(NewColumnName) to the datatable(dt)
  2. Then below codes is working by using assign activity
    dt.Columns(“NewColumnName”).Expression = “[Column1] * [Column2]”
1 Like

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