Order

Arranges members of a set, optionally preserving or breaking the hierarchy.

Syntax

 Order(Set_Expression, Value)
 Order(Set_Expression, Value, Symbol)

Arguments

Set_Expression
MDX expression that returns set.
Value
Value by which this set should be ordered
Symbol

ASC, DESC - orders ascending or descending within members hierarchy

BASC, BDESC - orders ascending or descending overriding members hierarchy

Examples

The following example would return resolution date of the last resolved sub-task of the issue.

  -- Order function starts
     Order(
		 -- set of sub-tasks for the issue
        Filter(
           Descendants([Issue.Sub-task].CurrentMember,
             [Issue.Sub-task].[Sub-task]),
           NOT isempty ([Issue.Sub-task].CurrentMember.Get('Resolved at'))), 
		 -- value for ordering
        [Issue.Sub-task].CurrentMember.Get('Resolved at') ,
     -- symbol
        DESC
     )
  -- Order function ends
  .Item(0).Get('Resolved at')

The next example aggregates all closed Sprints by Sprint start date ignoring Boards.

Aggregate(
-- Order function starts
  Order(
  -- set
    Filter([Sprint].[Sprint].Members,
      [Measures].[Sprint Closed?] = 'Yes' AND
      NOT isEmpty([Sprint].CurrentMember.Get('Complete date'))),
  -- value for ordering
   [Sprint].CurrentMember.Get('Start date'), 
  -- symbol
   BASC)
-- Order function ends
)

See also

Other examples are described in Calculated members page.