Sort Data Table: [PO] Order Id DESC isn't a valid Sort string entry


Excel data has been assigned to be numeric but output excel data still appear as text (apostrophe)
please help to resolve this.

Hi @beginner_RPA,
Here you have one possible way to sort your DT:
Use an Assign activity: dt1.AsEnumerable.OrderBy(Function(r) If(IsNumeric(r(“columnname”)), CDbl(r(“columnname”)), 0) ).CopyToDatable

Cheers!


it doesnt work

@beginner_RPA

Please put the sample data of DT and also output you want it will be easy to give you solution

image
input data as above

Hi @beginner_RPA ,
Try as follow:

DT.AsEnumerable.OrderBy(Function(r) If(IsNumeric(r("[PO] Order Id")), CDbl(r("[PO] Order Id")), 0)).CopyToDataTable()

Cheers!

it still doesnt work

Hi @beginner_RPA

=> Read Range Workbook
image
Output-> dt
=> Use below syntax in Assign:

sortedDataTable = dt.AsEnumerable().OrderByDescending(Function(row) row.Field(Of String)("[PO] Order Id")).CopyToDataTable()

sortedDataTable is of DataType System.Data.DataTable
=> Write Range Workbook sortedDataTable
image

Regards

@beginner_RPA

(From row In DT.AsEnumerable()
                      Order By Convert.ToDouble(row("[PO] Order Id")) Descending
                      Select row).CopyToDataTable()

Input:
image
Output:
image

You take a for loop to convert “[PO] Order Id” to double.Using this query there is no need for that loop so simply comment out or remove that loops

Hope it helps you

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