sum function
The sum function returns the sum of the column, evaluated within groups defined by the group parameter if required.
Parameters
sum(column, group)
Parameter | Description |
---|---|
column | The attribute used to evaluate the sum. Multiple attributes can be specified, as long as they are enclosed in double brackets, i.e. column((column1, column2)). In this occurrence, the sum will be calculated by row. The column parameter is mandatory. |
group | The attribute by which you want to group your results. If this parameter is a list, then the column parameter can’t be a list. |
Example
The following example uses the Students Performance dataset.
Description | Screenshot |
---|---|
In this example, we want to sum the values of the writing score attribute. Add a new attribute, then type the following formula:
The attribute has been filled with the sum of all the values in the writing score attribute. | |
If you want, you can choose to group the results. In this example, we want our results to be grouped by the test preparation course attribute’s values. The formula becomes:
The results can be read as follows:
| |
When the column value is a list, the formula considers the single rows of the attributes, so it sums considering the chosen attributes in rows. For example, if we want to know the sum of the math score, writing score, reading score of the student in row 1, the formula becomes:
The results can be read as follows:
|