How to group same Column Values into New DataTable

Hello Community,

i have Data Table like this

FieldNames GroupCheck
Field1 1
Field2 1
Field13 1
Field16 2
Field23 1
Field24 2
Field30 3
Field32 4
Field34 3

FieldNames and Numbers may go on…
I Need to group the Same number along with the field Name into new Data Table

output should be like this

Dt1:
Field1 1
Field2 1
Field13 1
Field23 1

Dt2:
Field16 2
Field24 2

Dt3:
Field30 3
Field34 3

Similar way Numbers may go up to 100 or 10000

Please give me a Soln

Thanks in Advance,

HI @nisarga

Input_dt.AsEnumerable.GroupBy(Function(x) x("ColumnName").ToString).SelectMany(Function(grp) grp).CopyToDataTable

Regards

Hi,

Can you try the following sample?

dict = dt.AsEnumerable.GroupBy(Function(r) r("GroupCheck").ToString).ToDictionary(Function(g) g.Key,Function(g) g.CopyToDataTable)

Sample
Sample20240626-5.zip (9.9 KB)

Regards,

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