Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to round the results of a calculation

Featured Replies

  • Newbies

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

You want to use the Round function.

Round( 1234.5678, 2 ) = 1234.57

Round( 1234.5678, 0 ) = 1235

Round( 1234.5678, -1 ) = 1230

Chuck

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 ]

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

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 ]

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.