In a formula-type column, the SUM_ELEMENTS() function adds up the numerical values of a column, including columns containing multiple values separated by commas, notably fields of the Linked Table Column type.
Some tools use the term "Rollup" for an equivalent function that calculates the sum of elements linked to a table.
-
Function name:
SUM_ELEMENTS()
Syntax
SUM_ELEMENTS(column)
Calling function parameters in TimeTonic:
- $field_name = field (link, linked table column, number, selection, formula, text...).
- "free text" = free text to add within quotes.
- do not use quotes for numbers.
Parameters
| Parameter | Description |
|---|---|
column |
The column whose values are summed. It can be a number-type column, or a Link to another table / Linked Table Column type, provided it contains numerical values. |
Example
A timesheets table (hours and costs) is linked to a projects table. The Cost from timesheets column is a linked table column that brings up the costs from each row. To get the total project cost:
SUM_ELEMENTS($Cost from timesheets)
The column returns the total costs of all timesheets linked to the project.
Notes
- The sum also works on text-type columns, Link to another table, or Linked Table Column, as long as they contain numerical values.
- You can hide the intermediate column (here
Cost from timesheets) so it is not displayed to the end user.
Return type
The function returns a number.
The output type format of the result can be configured in the output field options of the formula editor. For more details, see Output format options in the Formula Column article.
Business use case
SUM_ELEMENTS() consolidates linked data: total hours worked on a project, total labor cost, cumulative amount of orders linked to a customer.
Best practice
First create an intermediate column that brings up the value to be summed from the linked table, then apply SUM_ELEMENTS() on this column. Hide the intermediate column to keep the interface clean.