Tech Tip: Sorting Numeric values in an Alpha field
PRODUCT: 4D | VERSION: 16 | PLATFORM: Mac & Win
Published On: October 30, 2017
If you store numeric or alphanumeric values in an Alpha field, you may notice that sorting the field places 10 and 11 after 1 and before 2.
For example, sorting the values 1 through 13 in an Alpha field would result in an order like this:
To work with this behavior, we can use a formula.
From the Order By editor we can choose "Add Formula"
From the Formula Editor we can encapsulate the field we want to sort within a call to NUM() like this:
This will update the Order By Editor to look like this:
Clickin on the Sort button will apply this sort and the results will look like this:
This can also be done via the command ORDER BY FORMULA like this:
ORDER BY FORMULA([Table_4];num([Table_4]Field_2);>) |