How To Reverse A DataTable In UiPath

We may come across situations where we have to process the records available in excel or a data table in reverse.

So let’s explore how to do that in UiPath!!!

dt_Reverse = dt_Original.AsEnumerable.Reverse.CopyToDataTable

Note:
1. Simply replace the “dt_Original” with your required “DataTable”


Example

Implementation using UiPath :

Let us implement a workflow which takes a sample data table as input and outputs the reverse of it.

Step 1:
Drag “Build Data Table” activity into the design panel and populate it with some sample data.

UiPath Reverse a Datatable 1

UiPath Reverse a Datatable 2

Step 2:
Drag “Assign” activity into the design panel and fill it with above-mentioned code.

UiPath Reverse a Datatable 3.png

Step 3:
Drag “Output Data Table” activity into the design panel and convert Datatable to String type.

UiPath Reverse a Datatable 4UiPath Reverse a Datatable 5

Step 4:
Drag “Message Box” activity into the design panel to display the reversed data table.

UiPath Reverse a Datatable 6.PNG

Step 5:
Finally, let’s run the project.

UiPath Reverse a Datatable 7.PNG

Click here to download the Source Code…

Hope it has helped you…

Leave a Reply

%d bloggers like this: