How to combine string for each rows and sum amount and group by "Column Name"

Hi all, let me know how can I combine string values in “CLASS” column and sum “settledcommission” by Grouping “AGENT CODE” to get following data table result


The original data is attached as follow;


Can you share your worksheet as a file? it’s no problem if dummy data.


Hi Yoichi,

Kindly check the attached file for dummy raw data.
for_testing.xlsx (8.1 KB)


How about the following? This outputs result to sheet “Result”

dt = dt.AsEnumerable.GroupBy(Function(r) r("AGENT CODE")).Select(Function(g) dt.Clone.LoadDataRow({String.Join(",",g.Select(Function(r) r("CLASS")).Distinct),g.Key,g.Sum(Function(r) Double.Parse(r("settledcommission").ToString)) },False)).CopyToDataTable (9.8 KB)


Thanks, this solution works for me.

1 Like

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