How to group rows that have similar information and add the values before we merge them?

Step:1

| A1 | a | 2.2

| B2 | b | 2.2

| B2 | c | 1.3

| B2 | c | 5

| A1 | d | 6

| A1 | a | 7

Step:2

| A1 | a | 9.2

| B2 | b | 2.2

| B2 | c | 6.3

| A1 | d | 6

any help @AkshaySandhu

Hello @ANSHUL
Check this post it’s similar to your post & download the workflow for better understanding

let me know if you didnt understand any part !!

2 Likes

@ANSHUL I suggest you to review the @vickydas’s post…
this will definitely going to help you build the LINQ knowledge…
I was not able to find relatively better links but you can give below a try…
https://www.dreamincode.net/forums/topic/389471-linq-group-by-and-aggregates/

1 Like

Hi All thanks for all the document and guidance,
Finally managed to create a LINQ to add the values of data type double for Col3:

(From p In dt.AsEnumerable()
Group By x= New With { Key.a =p.Item(“Col1”),Key.b=p.Item(“Col1”)}
Into Grp = Group Select obj.LoadDataRow (New Object() {grp(0)(3), grp(0)(4),Grp.Sum(Function( r) CDbl(r(“Col3”))), grp(0)(8)},False)).CopyToDataTable

3 Likes

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