Loop through same column values and add the corresponding values which is in the other column

Am having an Excel report where I need to add the values in the B column if they come under the same ‘A’ column values.

Attaching a sample format of an Excel, here I need to add 45 and 30 as they come under the same value in A column

image

@aakhilanair7
find starter help here:
GroupBy_Sum_1Col.xaml (7.9 KB)

in case of you want to base it on Int32 base instead of double just go for this changed line:
Let ra = New Object(){k,grp.Sum(Function (x) Convert.ToInt32(x(“Column2”).toString.Trim))}
but ensure that all values within the datatable are valid Int32 strings

Thanks a lot, it worked!

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