# DAX Language – SUM and SUMX Functions

A-Badde | Posted on April 05, 20

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: ###### (0) Comments

There is no comment

##### Recent Posts
###### DAX Language - CONTAINS Function
A-Badde | May 09, 20

The CONTAINS function returns a boolean value, TRUE if each ...Read More

###### DAX Language - RANKX Function
A-Badde | May 05, 20

The RANKX function returns a single integer value that repre...Read More

###### DAX Language - AND and OR Functions
A-Badde | April 10, 20

AND/OR functions check whether all arguments are TRUE or one...Read More

###### DAX Language - Variables in DAX
A-Badde | April 10, 20

Use Var keyword to store the result of an expression as a na...Read More