Sorting Dynamicaly by ColumnName ASC/DESC


here i have a solution to sort Data dynamicaly by Parameter.

Is there a posibility to do this a little bit smarter? :slight_smile:

It would be realy fine to have a Sort-Action with Parameters SortColumnName and SortColumnOrder.
SortDynamic.morph (9.2 KB) (3.2 KB)
SortDynamic.dset (1.6 KB)



1 Like

Hi Adrian,

If I understand your question well, and if the sort column is never textual, I believe you could do this as follows:

  • load the .dset
  • Calculate new column as below, using the EVAL() function and (if the sort order is DESC) inversing the numeric sign
    if {txt_sort_mode} = 'ASC' 
    then eval('['&{txt_sortcolumnname}&']')
    else -eval('['&{txt_sortcolumnname}&']')
  • sorting on this colum, always ascending (as you have already covered the sort order when calculating the column)

If the sort column can also be textual, then the above won’t work. I would then reduce the computation to the eval() function without the condition on the ASC/DESC; and use the derived table approach that you’re currently using.

Example 1:

Example 2:

Come to think of it, and still supposing I understood your question well, it could be even more simple:

  • load the .dset
  • Calculate new column without the condition on ASC/DESC, so as below:
  • sort ascending on the calculated column
  • skip actions on condition: skip when {txt_sort_mode} = 'ASC'
  • sort descending on the calculated column

This would give:

1 Like

Hi David,
thanks for your solutions. Sorting by text is rare, but posible.
Anyway … i think both solutions are smarter then mine :slight_smile:

To have this feature in the Sort-Action would also be a nice idea :slight_smile: