Friday, September 02, 2011

FileMaker TIP: Number Suffix

Here's a tip for adding the number suffix - like 1st, 2nd, 3rd, 4th, etc. You can use the formula below as a calculation, or put it into a custom function. If you use it as a custom function the parameter name would be "dataNumber":

Let( [
   isException = Case(
   Mod (dataNumber; 100) = 11 or
   Mod (dataNumber; 100) = 12 or
   Mod (dataNumber; 100) = 13; 1) ;
   last = Mod ( dataNumber ; 10 )
];
Case ( isException ; "th"; last = 1; "st"; last = 2; "nd"; last = 3 ; "rd"; "th") )

Pretty simple - but powerful!

No comments:

Web Analytics