Get the top ten rows in a datatable

Hello,

I’ve got a DT from an Excel using “read range” activity. Then I sorted (descending) the DT using “Sort DataTable” activity, and getting a new DT (orderedDT).

And now my question:
Is there any way to obtain only the top ten rows from orderedDT?

Thank you in advance,

David Laosa

Hi,

Try this:

DT_Input.AsEnumerable().Take(10).CopyToDataTable

Thanks,
Muthuraj

Hi @dla,
Dt2 = Dt1.Clone Dt2=Dt1.AsEnumerable().Take(50).CopyToDataTable()

So First make clone of DT1 to get headers. Then run query.

Thanks

It works!

Thank you so much!!!

1 Like

Thank you so much.

It’s also a good solution, but I didn’t need headers this time.

Thanks again

@dla welcome, but you did not mention in your statement. So I gave you generic one

1 Like

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