SUM/CONTAINS Functions: Calculations in Tables
You can calculate fields in a table.
For example, you can perform the following calculations.
- Place calculated fields in a table and perform calculations in each row
- Use SUM function to calculate the total of numeric values in the table
- Use CONTAINS function to determine if the table has any row data that matches the search string (specified content)
This page explains these three calculations.
Place Calculated Fields in a Table and Perform Calculations in Each Row
You can place calculated fields in a table and perform calculations in each row.
For example, by using the quantity and the unit price in the table, you can set the formula "Volume*Unit_price" in the calculated field.
Sum Function: Calculating the Total of Numeric Values or Time Data in a Table
By using SUM function, you can calculate the total of values in the fields within a table.
For "Number1", specify the field code of the Number field, a formula that results in a numerical value, or a number.
|Formula (calculate subtotal): SUM (subtotal)
Calculate the total of numeric values entered in the "Subtotal" fields in the table.
Example: Summarizing the Subtotals in the Table
This section describes how to display the sum of subtotal values in the table into the "Total amount" field, by using an example of an order management app.
For details on tables, see the "Adding Tables into Forms" page.
From the parts list shown in the left side, drag and drop the Calculated field.
Open the screen to set the Calculated field, and enter "Total Price" as the field name.
Keep the screen open.
Enter the SUM function that calculates the total amount of values in the table.
In this example, enter "SUM(Subtotal)" to calculate the total amount of subtotals.
To make the total amount easy to read, select "Number with thousands separator (1,000)".
Change the field code to "Total_Price", and click Save.
Click Save Form on the upper left side of the screen, and then click Update App on the upper right side of the screen.
Now, the Calculated field to display the total amount of values in the table is set.
The sum of subtotal values in the table is displayed in the Total Price field.
TIPS: If Empty Fields Are Included
You can summarize the values even if empty fields are included in the calculation. The calculation result is reflected in the total amount as well.
Example: Calculate the Total of Time Data in the Table
In the Calculated field, you can calculate Date & time, Date, Time, and Hours in addition to numbers
For example, you can set "End-Start" formula, to automatically calculate the time taken to respond to an inquiry
You can also set a formula "SUM(Response_Time)" in the "Total Response Time" field, to sum up the time taken to respond to customers.
CONTAINS Function: Determining if Table Contains Any Row Data That Matches the Specified Condition
By using CONTAINS function, you can check if the table has any row data that matches the search string (specified content), and refer to the result in the formula.
|CONTAINS(Field_code, Search string)
It returns TRUE if the table contains any row where the field value specified in "Field_code" matches the string specified in "Search string". Otherwise, it returns FALSE.
- As the first argument, specify any of the text, radio button, drop-down, and lookup (if the data type of the copy source is a string) in the table.
- As the second argument, specify a search string.
This section shows you an example of a formula using CONTAINS function.
|Formula: IF(CONTAINS(priority, "speedy"), "Immediate response", "normal")
Determine if the table contains any row whose value is "speedy" by using CONTAINS function.
If the table has at least one row containing "speedy" in the "priority" field, it will display "Immediate response". Otherwise, it will display "normal".
The string for the second argument must be enclosed with double quotation marks ("").