How pick randomly 1000 rows from datatable where datatable contains 10k

Hi Team,

I have an excel with 10000 records and i want to form a other datatable with only 1000 records where 1000 picked randomly from whole datatable. Bot should not pick top 1000 or last 1000. Please help me on this.

Thanks in advance…!!

Try this;

  1. Order the rows in a data table randomly.

  2. Take the 1000 rows from the randomly ordered data table.

    Dim rand = New Random()
    Dim employees = employee.AsEnumerable().OrderBy(Function(rn) rand.Next).Take(10)

Karthik Byggari


Hi Kathik,

Using above syntax i’m getting top rows only it is not picking randomly.
Please see the image.

How many rows are in dt1?

total 5 rows


when printing using for each row always first 3 rows only printing.


Can you please try with more than 10 rows and let me know if the result is same.

Yes results are same.


Welcome to the uipath community.

Please check below thread and give it a try once.

How to get the unique records randomly from Data Table???

Okay. Let me check from my side and let you know the output.

Karthik Byggari

I am also getting only the top rows

Is there any solution to this?

Hi @Needhelp

Wait I will check and let you know the findings.

Hi @Needhelp

I posted a custom activity in the UiPath Connect.

Please download the package from here -

It will be soon available in the Manage Packages.

Karthik Byggari


It says that the resource does not exist

Oops. Can you send me the error screenshot to analyse.

I guess the component is in review. I will let you know once it is available in connect.
Sorry for delay.

Can any one please provide the solution for this


This worked for me in uipath. Just kept “Rand” s type as random.