Hi UiPath Forum community, I’m facing an issue while trying to work with Excel data in UiPath. I have successfully loaded the Excel data into a DataTable using the Excel Application Scope and Read Range activity. However, I’m unsure how to proceed with calculating the sum of all row values and column values in the DataTable.
How can I calculate the sum of all row values in the DataTable?
How can I calculate the sum of all column values in the Data Table?
For Each colIndex In Enumerable.Range(0, dataTable.Columns.Count)
colSum = dataTable.AsEnumerable().Sum(Function(row) Convert.ToDouble(row(colIndex)))
totalColumnSum = totalColumnSum + colSum
End For
Hi @ram_pv ,
Sum in column
sum= yourDataTable.AsEnumerable().Sum(Function(row) If(TypeOf row(column) Is Double, CDbl(row(column)), 0))
Sum in row
sum = row.ItemArray.Sum(Function(item) If(TypeOf item Is Double, CDbl(item), 0))
Regards,
LNV