# Sum of column groupped by identifier

Hello,

I had to do the sum of columns related to their identifier:

FR550 COMMON ENT2622837 31/03/2018 25200000
FR550 25200210
FR550 ENT2622837 25200230
FR550 ENT2622837 45200100
FR550 ENT2622837 45200000
FR550 ENT2622837 61540900
FR7K0 ENT2612259 45200000
FR7K0 ENT2612259 45200100
FRY90 COMMON 0012611448 25200130
FRY90 COMMON 0012611448 61540900
FRY90 COMMON 0012611448 45200100

keep only in a datatable: FR550 sum of th 4th column
FRY90 sum of th 4th column

hi @abdel

Check this

dt.Compute(“Sum(“FR550”)”, “”).ToString();

Thanks
Ashwin S

You can do it using group by in LINQ. Let me know if you need an example.

Compute Sum method requires ColumnName as parameter. You have given the value as parameter.

It should be something like this:
Convert.ToInt32(dt.Compute(“SUM(Column2)”, “Column1 =‘FR550’”))

Main.xaml (7.5 KB)

Hi @abdel,

You can use the groupbyAggregation Activity in the below package.

Regards
Balamurugan

Hi @abdel

Here I have attached the sample for your situation which is from " BalaReva.DataTable.Activities".

File : SumAbdul.zip
(13.7 KB)

This is the output.

You have to install the package like below.

You can sum up the columns based on a condition using a LINQ query.
see code below;

`````` **var sumOfA = dt.AsEnumerable()**
``````

** .Where(dr => dr.Field(“ConditionalColumn”).Equals(“A”))**
** .Sum(dr => dr.Field(“Column to sum”));**

You can also use a datatable compute function

See code below;
var sumOfA = dt.Compute(“Sum(Column to sum)”, “[Conditional Column] = ‘A’”);

Reference: