Article

DAX Language – SUM and SUMX Functions

DAX Language – SUM and SUMX Functions


A.Baddane | Posted on April 05, 21

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

Leave a Comment
Add to favorite
Categories
Recent Posts
Filter column based on a list in Power Query
A.Baddane | April 05, 23

Sometimes when you work within power query, you need to filt...Read More


Use HTML in Power BI - Part 2
A.Baddane | July 05, 22

In the first blog post about using HTML in Power BI Desktop,...Read More


Use HTML in Power BI
A.Baddane | Feb. 21, 22

In this blog post, I will show you how to use HTML to create...Read More


Covid-19 Report
A.Baddane | Nov. 23, 21

The COVID-19 pandemic, also known as the coronavirus pandemi...Read More