Hi, I am trying to get the the average of the last 3 rows with AddHeaders on. How can this be accomplish?
-
Use Read Range activity to read the data from Excel file and it will give output as DataTable. Let’s say dtInput.
-
And then try below expression.
int_avg = dtInput.AsEnumerable().Skip(dtInput.Rows.Count-3).Take(3).Average(Function(row) cint(row("Columnname").ToString))
Thank you. How do I round up and make sure there’s only one number after the decimal?
@RPA_Path Take assign activity and use the below exp
Variable Type Double Output = Math.Round(Input,1)
- Input is the variable that contains the decimal value
- Output variable contains the single value after decimal
Hi,
If you want to round precisely, I recommend to use MdipointRounding.AwayFromZero, as the following.
Math.Round(dt.AsEnumerable.Skip(dt.RowCount-3).Average(Function(r) Double.Parse(r("yourColumnName").ToString())),1,System.MidpointRounding.AwayFromZero)
Regards,
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.