Group Datatable

Hi All!

I have a datatable like this. I want to group by “Column1” adding values “Column2”
image
image

Excel is here
Datatable.xlsx (9.4 KB)

Hi @Betul_Dundar

What is your required output, Share an image or file.

File is added. in Sheet2 expected output

Hi,

How about the following sample?

dt.AsEnumerable.GroupBy(Function(r) r(0).ToString).Select(Function(g) dt.Clone.LoadDataRow({g.Key,g.Sum(Function(r) Double.Parse(r(1).ToString,System.Globalization.NumberStyles.Any,new System.Globalization.CultureInfo("es-ES"))).ToString("#,0.###",new system.Globalization.CultureInfo("es-ES")),g.First.item(2),g.First.item(3),g.First.item(4)},False)).CopyToDataTable

Sample
Sample20240125-8a.zip (9.7 KB)

Regards,

Thank you! It worked!!!

1 Like

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