How to group excel

In the data here, I want the sum of the “Net Ele Geçen Tutar” parts of the people with the same “T.C. Kimlik No” to be converted into a single line and transferred to a different excel file. How can I do this?
For Example;
The image is a segment of a spreadsheet showing tax-related information, including columns for T.C. Kimlik, Gelir Vergisi, Damga Vergisi, KDV, Tevkifat, Kesinti Toplamı, and Net Ele Geçen Tutar, with respective values for each item. (Captioned by AI)

data.xlsx (9.2 KB)

Hello @Umut_Veysel_DURKEN
You can try below logic:

dt_test 'Original input datatable
Dim dt_test as DataTable
dt_test2 = dt_test.Clone 'this will copy the structure of dt_test into dt_test2
dt_test2 = (from rw in dt_test.AsEnumerable group rw by k=rw("T.C. Kimlik No").ToString Into grp=Group select x = dt_test2.LoadDataRow(grp(0).ItemArray,True)).CopyToDataTable 'this will group the rows based on "T.C. Kimlik No" column

For each row as Datarow in dt_Test2.Rows 'this loop will assign sum value in column "Net Ele Geçen Tutar"
 row("Net Ele Geçen Tutar") = (from rw in dt_test.AsEnumerable where rw("T.C. Kimlik No").ToString = CurrentRow("T.C. Kimlik No").ToString group rw by k=rw("T.C. Kimlik No").ToString Into grp=Group  select grp.Sum(function(rw) CDbl(rw("Net Ele Geçen Tutar").ToString)))
Next row

Main.xaml (18.1 KB)

I got this far by doing what you said, I wonder what’s missing?

I believe only thing that you are missing is creating the dt_test2 variable.

I am able to open the xaml file but getting below error

Thank you problem is solved :slight_smile:

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