# 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?

Try this

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

Hope this helps!!

@robert_singval

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

cheers

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))
).CopyToDataTable
``````

Cheers…!

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

`

Hi,

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.