# How to calculate sum of total in datatable?

need to calculate sum of total all columns…entire datatable.

for example datatable,

Date column1 column2 column3 column4 column5 column6 column7 Total
1-3 17 10 15 4 47 15 56
3-7 9 4 3 14 4 1
Total 26 14 18 4 61 19 57

``````(From d In DT.AsEnumerable
Let t = {"Column1","Column2","Column3", "Column4","Column5","Column6","Column7"}.Sum(Function (x) Convert.ToInt32("0" & d(x).toString.Trim))
Let ra = d.ItemArray.Take(d.ItemArray.Length - 1).Concat({t}).ToArray
``````

Output:

Regards,

``````(From d In DT.AsEnumerable
Let t = {"column1","column2","column3", "column4","column5","column6","column7"}.Sum(Function (x) Convert.ToInt32("0" & d(x).toString.Trim))
Let ra = d.ItemArray.Take(d.ItemArray.Length - 1).Concat({t}).ToArray
``````

Hope it helps!!

Try this one.

Thanks,
Ashok

@saninfo273

If you find solution,Please do mark it as solution to close the loop and it will help others too.if you have any queries, can ask .

Regards

Here you go.

It’s easiest and simplest way.

Thanks,
Ashok

out put is incorrect

the output is incorrect…

Date KTN KCN KHC KCH KHO KSM KTV Total
03-Jan 17 10 15 4 47 15 56 4.10155E+12
07-Mar 9 4 3 14 4 1
Total 26 14 18 4 61 19 57 4.14186E+12

@saninfo273