Brian Dunning's FileMaker Custom Functions

NumToSortableText ( value ; decimals )

returns a textual representation of a number for sort purposes

  Average rating: 4.7 (30 votes) Log in to vote

Theo Ros   Theo Ros - Show more from this author

Share on Facebook Share on Twitter

  Sample input:
NumToSortableText ( 1234 ; 2 )

NumToSortableText ( -1234 ; 2 )
  Sample output:
90000000000001234.00

09999999999998765.99

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Returns a sortable textual representation of a numeric value.
To text-sort numbers, you will have to pad them with zeros.
To be able to cope with negative values, subfunction FlipDigits()
is used, to convert these into text, that when padded with nines
will turn the smallest value into the largest one.
Finally, positive values will be preceded by a "9", while negative
values will be prefixed wit a "0".
This will result in textvalues that will sort correctly, for instance
in a portal-sort solution.

Syntax: NumToSortableText ( value ; decimals )
Return type: Text

Uses function FlipDigits() defined earlier.

 

Comments

Jason Mark   Jason Mark, Northampton MA
May 10, 2013
Thanks!
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: