Compartilhar via


CurrentMember (MDX)

Returns the current member along a specified hierarchy during iteration.

Syntax

Hierarchy_Expression.CurrentMember

Arguments

  • Hierarchy_Expression
    A valid Multidimensional Expressions (MDX) expression that returns a hierarchy.

Remarks

When iterating through a set of hierarchy members, at each step in the iteration, the member being operated upon is the current member. The CurrentMember function returns that member.

Important

When a dimension contains only a single visible hierarchy, the hierarchy can be referred to either by the dimension name or by the hierarchy name, because the dimension name is resolved to its only visible hierarchy. For example, Measures.CurrentMember is a valid MDX expression because it resolves to the only hierarchy in the Measures dimension.

Example

The following example returns the order quantity of each product and the percentage of order quantities by category and model, from the Adventure Works cube. The CurrentMember function identifies the product whose order quantity is to be used during calculation.

WITH 
   MEMBER [Measures].[Order Percent by Category] AS
   CoalesceEmpty
   ( 
      ([Product].[Product Categories].CurrentMember,
        Measures.[Order Quantity]) / 
          (
           Ancestor
           ( [Product].[Product Categories].CurrentMember, 
             [Product].[Product Categories].[Category]
           ), Measures.[Order Quantity]
       ), 0
   ), FORMAT_STRING='Percent'
SELECT 
   {Measures.[Order Quantity],
      [Measures].[Order Percent by Category]} ON COLUMNS,
{[Product].[Product].Members} ON ROWS
FROM [Adventure Works]
WHERE {[Date].[Calendar Year].[Calendar Year].&[2003]}

See Also

Reference

MDX Function Reference (MDX)

Help and Information

Getting SQL Server 2005 Assistance

Change History

Release History

17 July 2006

Changed content:
  • Updated syntax and arguments to improve clarity.
  • Added updated examples.