I need to take first four row in datatable in uipath if the datatable has 4 rows leave it like that if it has more than 4 rows take only first four row
Can you try the following using Assign activity?
dt = dt.AsEnumerable.Take(4).CopyToDataTable
You can use if condition (row count >4) and the use the assign activity. It should work.
Please refer to the below post or simply use the method @Yoichi suggested.