Sum
The Sum function adds the numerical values in a column or group.
The Sum function is an aggregate function.
Aggregate functions evaluate one or more rows of data and return a single value.
In a table element, the aggregate is calculated for each grouping. For information on how to add a grouping with an aggregate calculation to a table, see Group columns in a table.
In a table with no groupings, the aggregate is calculated for each row. For information on how to calculate summary statistics across all rows in a table, see Add summary statistics to a table.
To learn more about using aggregate functions, see Building complex formulas with grouped data.
Syntax
Sum(column)
Function arguments:
- column (required) - The column of numbers to add together. Any Null or empty values are skipped.
Notes
- The sum function is different from the numeric operator
+in that it adds all of the values in a column or group, rather than adding multiple values together in the same calculation. For more information, see Operators overview - To return the sum of an entire column as an aggregate in each row, use the GrandTotal function with the sum function as the argument. For example,
GrandTotal(Sum([Cost]))returns the sum of the[Cost]column as a value in each row, which can be used to compare the[Cost]in each row to a total cost.
Examples
Sum([Price]) - Sum([Cost])
- In a table summary, finds the total profit for all rows in the table by subtracting the sum of Cost from the sum of Price.
- In a calculated column, finds the profit for each row by subtracting Cost from Price.
- In a grouped table, finds the profit for each group by subtracting the sum of Cost from the sum of Price for each group.
Sum([Profit])
- In a table summary, returns the total Profit for all rows in the table.
- In a calculated column, returns the Profit for each row.
- In a grouped table, finds the total Profit for each group.
If Profit contains values 2, 4, 6, 8, and 10, returns 30 when used in a table summary.
GrandTotal(Sum([Cost]))
In a calculated column, returns the total of Cost in each row of the table.
Updated 3 days ago
