TechNet
Expand All
Avg
IIf
Lag
Max
Min
Mtd
Qtd
Sum
Var
Wtd
Ytd
Collapse the table of content
Expand the table of content
Expand Minimize
This documentation is archived and is not being maintained.

CurrentOrdinal (MDX)

New: 17 July 2006

Returns the current iteration number within a set during iteration.


Set_Expression.CurrentOrdinal

Set_Expression

A valid Multidimensional Expressions (MDX) expression that returns a set.

When iterating through a set, such as with the Filter (MDX) or Generate (MDX) functions, the CurrentOrdinal function returns the iteration number.

Aa337085.note(en-US,SQL.90).gifNote:
The specified set must be an alias and cannot be a named set.

Example

The following example returns the number of products in the set that are unique, using the Order function to order the non-empty tuples before utilizing the Filter function. The CurrentOrdinal function is used to compare and eliminate ties.

WITH MEMBER [Measures].[PrdTies] AS Count
   (Filter
      (Order
        (NonEmpty
          ([Product].[Product].[Product].Members
          , {[Measures].[Reseller Order Quantity]}
          )
       , [Measures].[Reseller Order Quantity]
       , BDESC
       ) AS OrdPrds
    , (OrdPrds.CurrentOrdinal < OrdPrds.Count 
       AND [Measures].[Reseller Order Quantity] = 
          ( [Measures].[Reseller Order Quantity]
            , OrdPrds.Item
               (OrdPrds.CurrentOrdinal
               )
            )
         )
         OR (OrdPrds.CurrentOrdinal > 1 
            AND [Measures].[Reseller Order Quantity] = 
               ([Measures].[Reseller Order Quantity]
               , OrdPrds.Item
                  (OrdPrds.CurrentOrdinal-2)
                )
             )
          )
       )
SELECT {[Measures].[PrdTies]} ON 0
FROM [Adventure Works]

Release History

17 July 2006

Changed content:
  • Updated syntax and arguments to improve clarity.
  • Added updated examples.
Show:
© 2016 Microsoft