How to find max and average value from Datatable in UiPath

Many times we have been asked to calculate the max and average value from a dataset.

In this article , we will see how we can eaily achieve this LINQ query in UiPath.

Implementation in UiPath

Step 1:- Lets drag build DataTable activity in the designer panel & populate some value.

Step 2:- Drag message box activity in the Designer panel & use the LINQ query to get the maximum value from the data.

Max_Value:-

DataTable_Name.AsEnumerable().Max(Function(row) cint(row(“Column_Name”)))

Step 3:- Drag message box activity in the Designer panel & use the LINQ query to get the average from the data.

Average_Value:-

DataTable_Name.AsEnumerable().Average(Function(row) cint(row(“Column_Name”)))

Step 4:- Lets run the workflow now.

image

I hope you enjoyed the article!

Happy Automation!!

(
From row in DT
where row(“columnName”).tostrong.isNumeric
select row
).max(function (x) cint(x(“ColumnName”)))

by using this u can find max no in any in DT

1 Like

Another possibility

(
From row In DTSales
Select row
).Average(Function(x) CDbl(x(“Sales”).toString))

1 Like