Article

DAX Language - RANKX Function

DAX Language - RANKX Function


A.Baddane | Posted on May 05, 21

RANKX Function

 Description:

The RANKX function returns the rank of an expression in the list of values for each row in the table argument.

 Return Value:

RANKX returns a single integer value, representing the rank number of values among all possible values of expression.

 Syntax:

RANKX( <table>,<expression>[,<value>[,<order>[,<ties>]]] )
  • Description of the parameters:

PARAMETER

DESCRIPTION

Table

DAX expression that returns a table 

Expression

The expression is evaluated for each row of table

Value

DAX expression that returns a single scalar value whose rank is to be found. Optional

Order

Value that specifies how to rank value. Optional
0, FALSE or DESC: Rank in descending order
1, TRUE or ASC: Rank in ascending order

Ties

An enumeration that defines how to determine ranking when there are ties. Optional

 

 Example:

In this example, we want to add a measure that calculates the sales amount ranking for each product subcategory in the Product SubCategory table.

The following formula shows how to add a rank measure, that displays the rank of each Product Sub Category by Sales amount in descending order

Rank = RANKX(
            ALL(ProductSubcategory[ProductSubcategory]),
            [SumSalesAmount],,DESC
        )

 Note that:

  • When the value parameter is omitted, the value of expression at the current row is used instead.
  • Optional arguments might be skipped by placing an empty comma (,) in the argument list.
  • The default value for the Order argument is DESC.
  • The default value for the Ties argument is SKIP.

 

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