Is it possible to round off decimals to the nearest whole number when values are calculated?
To round off the calculation result, set a formula that uses the ROUND function.
Setting the ROUND function
This section provides an example of calculating the price including tax in the following way: multiplying the price excluding tax by the tax rate (e.g., 1.1).
On the app form, place a "Number" field, which will be used for entering the price excluding tax, and a "Calculated" field, which will be used for calculating the price including tax, and then set a formula that uses the ROUND function.
Field name | Field code | Field type | Formula |
---|---|---|---|
Price excluding tax | Price_excluding_tax | Number | - |
Price including tax | Price_including_tax | Calculated | ROUND(Price_excluding_tax*1.1)
Note: In order to get an integer, this example omits the second argument '0'. |
Setting the YEN function for a "Text" field
Besides setting the ROUND function, you can set the YEN function for a "Text" field to round off values.
When the YEN function is used, the calculation result will be displayed with '¥' (Yen) and thousands separators. Also, the calculation result will be a string.
Placing fields and setting a formula
This section provides an example of calculating the price including tax in the following way: multiplying the price excluding tax by the tax rate (e.g., 1.1), and then rounding off the result.
On the app form, place a "Number" field, which will be used for entering the price excluding tax, and a "Text" field, which will be used for calculating the price including tax, and then configure the fields as described below.
Field name | Field code | Field type | Formula |
---|---|---|---|
Price excluding tax | Price_excluding_tax | Number | - |
Price including tax | Price_including_tax | Text | YEN(Price_excluding_tax*1.1, 0) Note: Select Calculate automatically in the field setting. Since the YEN function requires two arguments, you cannot omit the second argument. |
Configuring the "Number of Decimal Places to Round" and "Rounding" settings
Check the settings for Number of Decimal Places to Round and Rounding in the Misc Settings.
-
Click the App Settings icon (the gear-shaped icon at the upper right of the "View" screen), select the App Settings tab, and then select Misc Settings under Advanced Settings.
-
Check that '4' and Round to the nearest even number are set for Number of Decimal Places to Round and Rounding respectively.
Settings for Number of Decimal Places to Round and Rounding are applied to the calculation result in the app and to field values used by formulas. -
Click Save at the bottom right of the screen.
-
Click Update App at the upper right of the screen.
-
On the confirmation dialog, click Update App.
When you configure the settings as described above and then enter "980" as the price excluding tax, the following calculation result is displayed.
- Price excluding tax: 980
- Price including tax: ¥1,078 (Auto-calculated value)
Besides setting the ROUND function or the YEN function, you can also use the "Precision of numbers and calculations" setting in the Misc Settings to process fractions.
For information on when to use the ROUND function and when to use the "Precision of numbers and calculations" setting, refer to Setting the Round Off, Round Down, or Round Up.
As a reference, the following describes the steps to process fractions using the "Precision of numbers and calculations" setting.
Using the "Precision of numbers and calculations" setting and "Calculated" fields
Set formulas for "Calculated" fields and configure the "Precision of numbers and calculation" setting as described below.
Placing fields and setting formulas
This section provides an example of calculating the price including tax in the following way: multiplying the price excluding tax by the tax rate (e.g., 1.1), and then rounding off the result.
Place the following fields and configure the settings as described below.
Field name | Field code | Field type | Formula | Other settings |
---|---|---|---|---|
Price excluding tax | Price_excluding_tax | Number | - | - |
Rounding | Rounding | Number | - | Default Value: 5 |
For calculating price including tax | For_calculating_price_including_tax | Calculated | Price_excluding_tax*110 | - |
Price including tax | Price_including_tax | Calculated | (For_calculating_price_including_tax/10+Rounding)/10 | - |
Configuring the "Number of Decimal Places to Round" and "Rounding" settings
Configure the settings for Number of Decimal Places to Round and Rounding in the Misc Settings.
-
Click the App Settings icon (the gear-shaped icon at the upper right of the "View" screen), select the App Settings tab, and then select Misc Settings under Advanced Settings.
-
In the "Precision of numbers and calculations" setting, set '0' and Round down for Number of Decimal Places to Round and Rounding respectively.
Settings for Number of Decimal Places to Round and Rounding are applied to the calculation result in the app and to field values used by formulas. -
Click Save at the bottom right of the screen.
-
Click Update App at the upper right of the screen.
-
On the confirmation dialog, click Update App.
When you configure the settings as described above and then enter "980" as the price excluding tax, the following calculation result is displayed.
Price excluding tax | 980 |
Rounding | 5 |
For calculating price including tax | 107800 (Auto-calculated value) |
Price including tax | 1078 (Auto-calculated value) |
In the "Rounding" field, enter '9' to round up, '0' to round down, or '5' to round off.
By changing which value to enter in the "Rounding" field in each record, you can choose whether to round up, round down, or round off the value.