How to read ExtractedData in inverse

Hey everyone,

I am using Extract DataTable and I want to read the extracted values in reverse order. Can anyone please guide me on how to do that? Any help in this regard would be highly appreciated.

Thanks in advance!

1 Like

@Muhammad_Anas_Baloch

Reverse order means? 10 to 1 is it that?

Do you have any field to sort ascending to descending?

Thanks,
Srini

1 Like

Hi @Muhammad_Anas_Baloch

You can add a column to the data table & fill the column with numbers. Now, sort the data table in a descending order based on this column & remove the ignore the same column using default view. Now you have the source data table sorted in descending order.

Hope this helps,
Best Regards.

1 Like

Hi @Muhammad_Anas_Baloch

Try this to reverse the datatable

out_dt = in_dt.AsEnumerable.Reverse.CopyToDataTable

Regards,

1 Like

Yes you got the reverse order correct. I am using extract table which extracts the data from website. Now I want a For Each DataRow in table, but this will iterate the table from the index 0 to n index. I want to iterate it from n to 0 in For Each DataRow.

Could you please refer me any tutorial or article for this if you have any?

@Muhammad_Anas_Baloch

If you have any numeric field you can make asceding and descending depending upon your requirement

If you dont have such field you can try as @supriya117 suggested

Thanks,
Srini

1 Like

Sure I will try this.

Data is in String field.

@Muhammad_Anas_Baloch

Try this way

My Datatable is having order of this

image

Now used Assign activity and pass a datatable and write as below

DatatableVariable.AsEnumerable.Reverse.CopyToDatatable()

The the results are as below

image

Hope this may help you

Thanks,
Srini

1 Like

Thank you I think the same method above explained by @supriya117

Hi @Muhammad_Anas_Baloch,

To read extracted data table in reverse, you can simply use loops as follows -

int temp=extractedDT.Rows.Count
While(Temp>=0){
return datarow = extractedDT(Temp)
Temp = Temp-1
}

All the best,
:heart_eyes:

1 Like

Hi @Muhammad_Anas_Baloch

u can directly use the code in the foreach row in datatable activity like this

image

It will iterate reverse order only

Hope u doing great!!!

Thanks
VP

1 Like

@Muhammad_Anas_Baloch

Yes, the same I mentioned to try on @Supriya_Singh

Thanks,
Srini

1 Like

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