Filter DataTable to pull any (Top Or Random) 5 records for each user

Hello,

I have a table with some data and every row as assignee name, I have around 100 records with diff assignees, but I have to pull only any 5 rows for each user from the data table. Kindly help me to filter this scenario,

Thanks in advance.!

SampleData.xlsx (9.4 KB)

Hi @ramesh_kola

Have a look on the thread

Regards
Gokul

Hi,

How about the following?

dt = dt.AsEnumerable.GroupBy(Function(r) r("Assignee").ToString).SelectMany(Function(g) g.Take(5)).CopyToDataTable

Regards,

1 Like

Thank you it worked!

@ramesh_kola
We do understand following:

for each user pickup up randomly 5 records belonging to the user

Variables:
grafik

Flow:
grafik
Readin excel, grouping the data, Preparing the result table

Process the groups

Find starter help here:
ppr_ExcelBox_RameshKola.xaml (12.4 KB)

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