How to sum values of a column based on another column value

Hi,

I need to sum some values based on another column value since I will not know what values I got in Column01

Example

Column01 | Column 02
A --------------------10
A -------------------- 5
A -------------------- 7
A -------------------- 8
B --------------------10
B --------------------- 2
B ----------------------3
B ----------------------4

Result - A = 30| B = 19 and so on…

Thanks in advance!

Regards,

Alamyr

@Alamyr_Junior
have look on the component from connect channel:
grafik

on the activities Group By Aggregation, Native Aggrgation

Or you can do it with linq

Assign Activity:
left side: dtResult - Datatype Datatable
right side: yourDatatableVar.Clone

Assign Activity:
Left Side: dtResult
Right Side:

(From d in YourDataTableVar.AsEnumerable
Group d by k=d(“Column01”).toString.trim into grp=Group
let ra = new Object(){k,grp.Sum(Function (x) CInt(x(1).toString.Trim))}
Select dtResult.Rows.Add(ra)).CopyToDataTable

2 Likes

Thx ppr! I’ll try it!

@Alamyr_Junior
Find starter help here.
GroupBy_Sum_1Col.xaml (7.7 KB)

1 Like

Thanks, BalaReva Activities didn’t work because I don’t have onle integers values. I got 10.23, 9.33, etc…

@Alamyr_Junior
ok, I will adopt my xaml for this case.

But please us in a next time the requirements as its is. In you samples from above was not a single hint, that doubles are to handle. Thanks

1 Like

@Alamyr_Junior
find updated starter help now handling double values
GroupBy_Sum_1Col.xaml (7.9 KB)

Yep, I didn’t realize when I post it, sorry about that and thanks for the help!

Actually, the activities have a double option, if think it will work!

check sample data, it has values without decimals as well

Hi @Alamyr_Junior,

Check this video. Not only integer. it can handle integer and double.

Thank you
Balamurugan.S

3 Likes

Hi Balamurugan,

I already solved the issue using your activities, thank you very much. I didn’t realize about the doubles right on but after search more about the activity I could use easily.

Regards,

Alamyr

1 Like

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