Brian Dunning's FileMaker Custom Functions

SuperCeiling ( Number , RoundTo )

This custom function rounds up a number to the closest RoundTo Number

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

Ibrahim Bittar Torres   Ibrahim Bittar Torres - Show more from this author
Eikonsys, S.A. de C.V.
http://www.eikonsys.com

Share on Facebook Share on Twitter

  Sample input:
SuperCeiling ( 678 , 1000 )
SuperCeiling ( 4567 , 10 )
  Sample output:
1000
4570

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

(Updated Nov 28 - 2012):

Sometimes you need to calculate the closest thousand or hundred of a number, specially when you are working with items billable by the thousand (like paper).

Basically this CF divides the number by RoundTo, takes the fractionary part and rounds it up using the Ceiling() function and the adds it to the integer part and multiply it by RoundTo again.

 

Comments

Simon Stock   Simon Stock, Bedfordshire, UK
May 14, 2013
I get a "Specified Parameter Could Not Be Found" error, highlighting "Number" - what does that refer to?
 
Ibrahim Bittar   Ibrahim Bittar, Leon MX
May 14, 2013
You have to add the parameter in the upper side of the dialog. Type "Number" and click the + icon.
 
Steve M   Steve M, Broomall, PA
Aug 21, 2015
Works great!, found this after doing it the hard way....:)
Let([
hund=Right(Round(Service::odometer;0);3);
rnd=Case(
hund > 500;0;
hund = 500;-500;
hund ≥ 1 ; 500;
0)
];
Round(Service::odometer;-3)+rnd
)
 
Ibrahim Bittar   Ibrahim Bittar, León MX
Aug 21, 2015
Hi Steve, thank you for your comments.

By the way, it helped me to notice that it was spelled wrongly and I have just fixed it. the calculation remains the same, it was just how it shows on this website.

Thanks!
 
Don Wieland   Don Wieland, DW Data Concepts
Dec 22, 2017
If you want to make the result Round UP or Down, here is a MOD to your CF:


RoundUpDnByUnit ( Number , RoundTo )



Let ( [

a = Number;
b= RoundTo;

Num = a / b ;
Integ = Int ( Num ) ;
Frac = Num - Integ;

c = ( Integ + Ceiling ( Frac ) ) * b;
d = If(a ≥ (c - (b / 2)); c; c - b)

] ;

d )

Thanks!

Don
 

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: