How to Average the Entire column in Excel

I have Excel sheet with Three columns like ClientId, ClientName and Client Amount ,I want to average the Client Amount?

Thanks in advance for your help!

Hi @robert_singval

Try this

Avg=Dt.AsEnumerable().Average(Function(row) row.Field(Of Double)("Client Amount")).ToString

Hope this helps!!


Avg=dt.AsEnumerable.Average(Function(x) CDbl(x(“Client Amount”).ToString)).tostring


Hii @robert_singval

Try this Linq Query

From row In DT
Group row By a =  row("ClientName") Into grp = Group
Let b = grp.Average(Function(x) CDec(x("Client Amount").ToString.Trim))
Select DT1.Rows.Add({a,b})



Avg=Dt.AsEnumerable.Average(Function(row) row.Field(Of Double)(“Client Amount”)).ToString



you can use below expresssion:

Assign Activity

AverageAmount = YourDataTable.AsEnumerable().Average(Function(row) Double.Parse(row(“Client Amount”).ToString()))

We use the AsEnumerable() method to convert the DataTable into an enumerable collection.
We use a Lambda expression to extract and convert the “Client Amount” values to Double, and then calculate the average.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.