Hi Team,
Attaching an excel, i want that if column R is lessthan 1 or greater than -1 then replace it with 0.
I want it to do it with the help of LINQ. Please help.
OutputFile.xlsx
(1.3 MB)
we suggest to invest some time into LINQ learning:
[HowTo] LINQ (VB.Net) Learning Catalogue - Help / Something Else - UiPath Community Forum
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum
For coversions have a look at:
CDbl(…
Convert.ToDouble(…
Double.Parse(…
Hi
@yash.choursia
write the new dt based on condition using below linq
syntax : DT.AsEnumerable.Where(Function(r) if(double.parse(r(column name).ToString) < 1 or double.parse(r(columnname).ToString) > -1 ,True,False)).CopyToDataTable
and write the new dt values as zero using below linq
syntax : New DT.AsEnumerable.select(Function(r) New DT.Clone.LoadDataRow(New Object(){r(0).ToString,“0”},false)).copytodatatable
use invoke code activity
where in_dt=inputdatatable
For Each r As DataRow In in_dt.AsEnumerable
r(“Difference between Before Tax Amount”)=If((Math.Abs(CDbl(r(“Difference between Before Tax Amount”).ToString)))<1, “0”, r(“Difference between Before Tax Amount”).ToString)
Next r
You can try the following code
(From row In dt.AsEnumerable
Let updateDiffer = If(CDbl(row(17).ToString) > -1.00, If(CDbl(row(17).ToString) < 1.00,"0",row(17).ToString),row(17).ToString)
Select ra = row.ItemArray.Take(17).Append(updateDiffer).Concat(row.ItemArray.Skip(18)).ToArray
Select dt.Clone.Rows.Add(ra)).CopyToDataTable