Enable Calculations
At times, it may be necessary to run simple math calculations within a forms, such as addition or multiplication. To use calculations with a Number, Currency, or Option Range gadget, they will need to be enabled by selecting the toggle within the settings.
- Begin by adding either the Number, Currency, or Option Range gadgets to the form to house the total for the calculation.
- Next, enable calculations by toggling on the Enable calculations option within the settings for the total field.
- Select the type of calculation (sum, subtract, product, etc).
- After you have selected the type of calculation to use, you can select the Number, Currency, or Option Rage field you wish to calculate (ie: Field 1, Field 2, etc).
- When the user enters a value into the two fields selected, the calculation will be shown in the enabled field.
Types of Calculations
Below outlines the available options in the Type of Calculation dropdown:
- Sum - Adds all provided values together and returns the total.
- Subtract - Subtracts values in sequence, starting with the first value and subtracting each subsequent value.
- Product - Multiplies all provided values together.
-
Divide - Divides values in sequence, starting with the first value and dividing by each subsequent value. Example:
10 ÷ 5 = 2. Results are rounded to three decimal places. - Avg - Calculates the average by adding all values and dividing by the total number of values.
- Median - Returns the middle value when all values are sorted in numerical order. If there is an even number of values, the median is the average of the two middle values.
- Min - Returns the smallest value from the list of provided values.
- Max - Returns the largest value from the list of provided values.
- Count - Returns the total number of values included in the calculation.
- Floor - Rounds a single value down to the nearest whole number, regardless of the decimal value.
- Ceil - Rounds a single value up to the nearest whole number, regardless of the decimal value.
- Round - Rounds a single value to the nearest whole number. Values with a decimal less than 0.5 round down. Values with a decimal 0.5 or higher round up.
Calculations for Currency
When using calculations for currency, it’s important to make sure you’re setting the current output for the total.
For example, I want to calculate the dollar amount of sandwiches multiplied by the number of sandwiches purchased (currency x amount = $ total).
- For this example, you would need to add a currency gadget for Cost of Sandwiches, a number gadget for Number of Sandwiches, and a currency widget to house Total Sandwiches.
- Once the fields are established, toggle the Enable calculations setting to turn it on.
- For determining the total, select product under Type of Calculation, and then select Cost of Sandwiches for Field 1, and Number of Sandwiches for Field 2.
- Change the toggle at the top of the form to Preview.
- Enter the appropriate values into the fields, and the Total Sandwiches Cost will automatically calculate!
The enable calculations setting is only available on the Number, Currency, and Option Range gadgets.
Change currency
The currency gadget can now be configured for different currencies. By default it is set to USD but once Change currency is enabled you can change to one of the following: US dollars, Canadian dollars, Chilean peso, Euros and the British Pound. The currency is not automatically detected based on internationalization functionality in Kuali. It must be set in the gadget specifically. However, the display of the currency will automatically display based on the selected browser locale. The Number of decimals option allows you to limit the number of decimals the entry will allow. Here is the config option on the Currency gadget:
Enable Calculation Footer
At times, it may be necessary to run simple math calculations within a forms, such as addition or multiplication. To use calculations for number or currency gadgets within a table or repeater, the calculation footer will need to be enabled by selecting the toggle within the settings.
Once the table or repeater gadget has been add to the form:
- Toggle the Enable Calculation Footer option within the table settings.
- For each item in the table, select the type of calculation. For example, selecting sum will add the values of the column together.
- When the user enters a value into the fields selected, and the sum for each column will be calculated automatically in the footer.
The calculation footer setting will only be available for the table and repeater gadgets.
Comments
0 comments
Article is closed for comments.