Jump to content

This topic is 8641 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies
Posted

I'm rather new at this and attempting to round the results of a calculation. I want a calculation to have no more than two numbers behind the comma.

Please can someone help me

Thanks, Jeroen

Posted

You want to use the Round function.

Round( 1234.5678, 2 ) = 1234.57

Round( 1234.5678, 0 ) = 1235

Round( 1234.5678, -1 ) = 1230

Chuck

Posted

Slick! I'd never noted the use of the negative value with the "round" function before. But let me offer a more generalized approach for rounding to any unit, whether or not it's a decimal value.

Say, for example, you want a dollar calculation to be rounded to the nearest quarter. First, do the calculation in the usual way. Then, convert the result to quarters, by dividing by 25. Then round using round(result,0). Then, convert back to dollars. Of course, this can be done in a single calculation line.

This works for any type of unit; nickels in a dollar, gallons in a barrel, miles in a bunch of feet or feet in some number of miles, and pigs in a poke.

Bill Holt

edit: sprelling

[ June 06, 2001: Message edited by: Bill Holt ]

Posted

There could be another way of rounding off your Calculation. Simply use the Number format to show x amount of numbers after the comma etc. Select the field with CTRL held and select the option.null

Posted

quote:

There could be another way of rounding off your Calculation. Simply use the Number format to show x amount of numbers after the comma etc. Select the field with CTRL held and select the option.null

Selecting Format->Number to round a number field does not round the number, it just alters how it is displayed. This may or may not be sufficient. If the calculation is used in other calculations or summaries, rounding will effect this further calculations or summaries, formatting the number will not.

A simple example. If we have two calculation number fields Field_1 has a value of 1.234 and Field_2 has a value of 2.322. Calc_Field is set to Field_1 + Field_2, in this case 3.556. If the two fields are set to display so that only two decimals show, they will show up on the layout as 1.23 and 2.32 and the calc field wil show up at 3.56, but 1.23 + 2.32 = 3.55, not 3.56. The number if off as it is visible to the user. However, if Field_1 and Field_2 had used the Round function to round to the nearest hundreth, they would actually have values of 1.23 and 2.32 and the subsequent calculation field would be correct when viewed.

Admittedly, this might not be an issue, and in this case, what is viewed is only off by 1/100th, but such errors could easily accumulate in a summary field that takes a total across thousands of records, and the odds are that this would happen about half the time. For 10,000 records then, you could expect a summary field to be off by about 50 (10,000 * .01 * .5), which may be significant to the solution.

Chuck

[ June 07, 2001: Message edited by: Chuck ]

This topic is 8641 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.