Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculation question - how to round the answer up

Status
Not open for further replies.

blanchc

Technical User
Jun 9, 2015
3
0
0
US
I have a calculation field of: field1/500. That calculation field is working; however, the answer has to round up.
Example: $4,235,623.00/500=$8471.246 The answer of $8471.246 has to round UP to the next whole number. I tried making the answer 0 decimal points but it then follows the .50> up, .49< rounds down. I thought it may have to be written as a javascript, but I'm not sure how to do that. Anyone have any ideas? Your input would be appreciated. Thanks!
 
Hi there,

the "Ceiling" function is your friend:
Code:
Math.ceil(8471.246)
will give you 8472.

Will that do?

"Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family." (Kofi Annan)
Oppose SOPA, PIPA, ACTA; measures to curb freedom of information under whatever name whatsoever.
 
Thank you! So how would I write that in my Field1/500 calculation?
 
To be honest, I do not have experience with caluclation fields.
However one of the following should work:
In properties, change calculation to "user-defined calculation script", enter
Code:
Ceil(Eval(form1.field1)/500)

FormCalc is different to Javascript.
In Javascript you could also add a Javascript action to the Lost Focus or Mouse out event of field1:
Code:
this.getField("yourcalculationfield").Value=Math.Ceil(this.getField("field1").Value;

"Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family." (Kofi Annan)
Oppose SOPA, PIPA, ACTA; measures to curb freedom of information under whatever name whatsoever.
 
I will try those. Thank you very much for your quick and detailed responses. They are appreciated!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top