Sum amount column and output the result in the next empty row

Hi devs, I would like to sum column and output result in next row as shown

image
output -
image

Hi,

Can you try the following?

Main.xaml (8.0 KB)

Regards,

Hi Yoichi, check if this expression is right dtTest.AsEnumerable.GroupBy(Function(r) r(“S/n”).ToString).Select(Function(g) dtTest.Clone.LoadDataRow({g.key}.Concat(dtTest.Columns.Cast(Of DataColumn).Skip(1).Select(Function(c) g.sum(Function(r) If(Int32.TryParse(r(c).ToString,New Int32), Int32.Parse(r(c).ToString),0)).ToString)).ToArray,False)).CopyToDataTable
The output is this having 0 on the rows without number, I don’t want those zero’s here
image
Regards

Hi,

The above expression means

Group by first column(S/n)
Calculate sum all column except S/n for each group

So this won’t fit your requirement.

Regards,

How do we sum only the amount column

Hi,

In the above sample, we use AddDataRow activity with the following expression.

{"Total",Now.ToString("MM/dd/yyyy"),"-",dt.AsEnumerable.Sum(Function(r) Int32.Parse(r("SUM").ToString))}

Regards,

1 Like

Regards Yoichi, one more thing is to check and insert rows above by moving/cut the row with the total sum to other rows having total together as shown
image

Hi,

I think it’s better to handle them as 2 datatable (datatable for total and datatable for each item)
Then, just use AddDataRow to datatable for total.

Regards,

Alright, I will try it out

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