SUM Function
Description:
The SUM function adds all the numbers in a column.
Return Value:
SUM returns a single value, result of the sum.
Syntax:
SUM( <ColumnName> )
- Description of the parameter:
PARAMETER |
DESCRIPTION |
ColumnName |
The column that contains the numbers to sum |
Example:
To calculate the sum of sales amount in the Sales table, we can use the following formula:
SumSalesAmount = SUM(Sales[SalesAmount])
The SUM function will add all the numbers that are contained in the column [SalesAmount] from the table, Sales.
SUMX Function
Description:
The SUMX function calculates the sum of an expression evaluated for each row in a table.
Return Value:
SUMX returns a single value, result of the sum.
Syntax:
SUMX( <table>, <expression> )
- Description of the parameters:
PARAMETER |
DESCRIPTION |
Table |
The table containing the rows for which the expression will be evaluated. |
Expression |
The expression to be evaluated for each row of the table. |
Example:
In the Sales table, we want to calculate the sum of sales amount where the value of the column [UnitPrice] is greater than $1000.
Using the FILTER function, we’ll filter the table and pass the result of the expression to the SUMX function as a table parameter to calculate the sum of the sales amount.
SumxSalesAmount = SUMX( FILTER('Sales', 'Sales'[UnitPrice] > 1000), Sales[SalesAmount])
The SUMX function takes as its first argument a table, or an expression that returns a table (As in our example). The second argument is a column that contains the numbers you want to sum, or an expression that evaluates to a column.
Related Video: