Jump to content
Salesforce and other SMB Solutions are coming soon. ×

Way to sort (or rearrange) numbers in a field


TPAairman
 Share

Recommended Posts

I have a field with a 4 digit number from 0000 to 9999. What I need is a way for FMP to rearrange the digits in the field so the are in order. Or another field using a calculation is fine. So for example, if I have 4231, it would rearrange them to 1234. 3421 would also be 1234.

Link to comment
Share on other sites

Do you have FileMaker Advanced at your disposal, or only FileMaker Pro?

 

If you have FileMaker Advanced you can paste in a custom function. Brian Dunning's custom function site has a good bubblesort that sorts values, and you can break up your four digit number into four values and then bubblesort the results.

 

Links:

SortArray

SortArray Merge

 

Let (fourvalues = middle (YourField; 1; 1) & "¶" & middle (YourField; 2; 1) & "¶" & middle (YourField; 3; 1) & "¶" & middle (YourField; 4; 1); Substitute (SortArray (fourvalues; "Des"; "Number"); "¶"; "") )

 

 

That formula will

 

• take your 4 digit number and break it into four hard-return-delimited values;

• sort them numerically in descending order;

• then recombine them into a new 4 digit character string

 

 

do it as a calculation field, result type "text" so as to preserve leading zeros.

Link to comment
Share on other sites

 Share



×
×
  • Create New...

Important Information

Terms of Use