Article

DAX Language - RANKX Function


A-Badde | Posted on May 05, 20

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

Your email address will not be published. Required fields are marked *

Add to favorite
Categories
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