Dear all,
i have a data table for example
Jan - 2.3
Feb - 2.4 …
To multiply them by 1000.
Jan - 2300
Feb - 2400 …
is there a efficient way without using for loop?
Appreciate any help!!
Dear all,
i have a data table for example
Jan - 2.3
Feb - 2.4 …
To multiply them by 1000.
Jan - 2300
Feb - 2400 …
is there a efficient way without using for loop?
Appreciate any help!!
Hi @winnie_toh
yourDataTable.AsEnumerable().ToList().ForEach(Sub(row) row("YourColumnName") = Convert.ToDouble(row("YourColumnName")) * 1000)
E.g. have a look at the described approach of using DataColumn.Expression
remove
HI @winnie_toh
Please use the below syntax in assign activity
dtResult= dt.Clone()
dtResult= (From d In dt.AsEnumerable Let gp = d.Field(Of Double)("Value")*1000 Let ra = d.ItemArray.Take(1).Append(gp).ToArray Select dtResult.Rows.Add(ra)).CopyToDataTable
Regards
Hi @winnie_toh
If the values are in the same column.
Then take an for each row in datatable activity to iterate the each row in the datatable.
Inside for each use assign activities to multiple with 1000.
Check the below image for better understanding.
- Assign 1 -> MonthName = CurrentRow("Column name").ToString.Split("-").First.ToString.TrimEnd
- Assign 2 -> Values = (Cint(CurrentRow("Column name").ToString.Split("-").Last.ToString.TrimStart)*1000).ToString
- Assign 3 -> CurrentRow("Column name") = MonthName+" - "+Values
Hope it helps!!
hi Thank you! however i kept encountering firstly “Value” not found. so i replace it with “Jan”. but still same error occur. i assume i have to do 12 times from Jan to Dec too right?
Dt.AsEnumerable.Select(function(x) Dt.Clone.Rows.Add(x(“ColumnName”).ToString.Split(“-“c)(0)+”-”+(cdbl(x(“ColumnName”).ToString.Split("-"c)(1))*1000).ToString)).CopyToDataTable
Cheers!!