Unfortunately there is no way to reverse the sort order on non categorical data such as dates and numbers on columns or filters from the user interface without scripting.
Without scripting (calculated column)
Repeat("0",Max(Len(String(DenseRank([Date],"desc")))) - Len(String(DenseRank([Date],"desc")))) & DenseRank([Date],"desc") & " - " & [Date] as [DDate]
With scripting
def sortDates():
dateOrder=[]
dateVals =
dataTable.Columns['Date'].RowValues.GetEnumerator()
for d in
dateVals:
dateOrder.Add(d.ValidValue)
dateOrder.sort(reverse=True)
dataTable.Columns['Date'].Properties.SetCustomSortOrder(dateOrder)
print
dateOrder
sortDates()
3 comments:
Instead of using the calculated column you can use column sort order itself in column properties
Thanks for your comment Shaheerkp,
Your thought process is good, however the reverse option only works with string data type (text), so you will have to convert the data type into string and change the date formatting to have the proper sorting.
this is awesome. I don't remember how many times I told others this is impossible except for option 1 (without scripting). Option 2 get this done beautifully. Thank you for sharing.
Post a Comment