How calculate sum of total below datatable…
Unit
TN
CN
HC
CH
HO
SM
CB
KM
MH
Total
1-30
0.067817008
0.062174952
0.780147434
1.4210211
0.06174
0.923536262
2.024384096
0
1.173270112
30-60
0.0084672
0.01292592
0.011495
0.679251706
0.05530112
0.786329264
0.543732924
0.777522864
60-120
0.296024382
0.282708174
0.076847568
0.910708064
0.036481088
2.85786414
Total
0.375345166
0.357809046
0.916687522
3.01098087
0.11704112
1.709865526
5.508738467
21.30802436
4.031134252
Hi @domsmgtmeet22
Check this thread,It might helps you
Hi @saninfo273
(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
Select DT.Clone.Rows.Add(ra)).CopyToDataTable
[image]
Hope it helps!!
Hi @saninfo273
Please check this
[image]
(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
Select DT.Clone.Rows.Add(ra)).CopyToDataTable
Output:
[image]
Regards,
Hope it helps!!
Yoichi
(Yoichi)
May 9, 2024, 8:52am
3
HI,
Can you try the following sample?
Dim arrCol As String() ={"TN","CN","HC","CH","HO","SM","CB","KM","MH"}
dt.AsEnumerable.ToList.ForEach(Sub(r)
r("Total")=arrCol.Sum(Function(s) If(Double.TryParse(r(s).ToString,New Double),Double.Parse(r(s).ToString),0))
End Sub
)
Sample
Sample20240509-5.zip (18.0 KB)
Regards,
how to use assign activity ??
Is not working share another code