Skip to content

Latest commit

 

History

History
37 lines (30 loc) · 1.83 KB

File metadata and controls

37 lines (30 loc) · 1.83 KB
title Using Member Functions
description Using Member Functions
ms.date 02/17/2022
ms.service sql
ms.subservice analysis-services
ms.topic reference
ms.custom mdx

Using Member Functions

A member function is an Multidimensional Expressions (MDX) function that returns a member. Member functions, like tuple functions and set functions, are essential to negotiating the multidimensional structures found in [!INCLUDEssASnoversion].

Of the many member functions in MDX, the most important is the CurrentMember function, which is used to determine the current member on a hierarchy. The following query illustrates how to use it, along with the Parent, Ancestor, and Prevmember functions:

WITH  
//Returns the name of the currentmember on the Calendar hierarchy  
MEMBER MEASURES.[CurrentMemberDemo] AS [Date].[Calendar].CurrentMember.Name  
//Returns the name of the parent of the currentmember on the Calendar hierarchy  
MEMBER MEASURES.[ParentDemo] AS [Date].[Calendar].CurrentMember.Parent.Name  
//Returns the name of the ancestor of the currentmember on the Calendar hierarchy at the Year level  
MEMBER MEASURES.[AncestorDemo] AS ANCESTOR([Date].[Calendar].CurrentMember, [Date].[Calendar].[Calendar Year]).Name  
//Returns the name of the member before the currentmember on the Calendar hierarchy  
MEMBER MEASURES.[PrevMemberDemo] AS [Date].[Calendar].CurrentMember.Prevmember.Name  
SELECT{MEASURES.[CurrentMemberDemo],MEASURES.[ParentDemo],MEASURES.[AncestorDemo],MEASURES.[PrevMemberDemo] } ON 0,  
[Date].[Calendar].MEMBERS ON 1  
FROM [Adventure Works]  

See Also

Functions (MDX Syntax)
Using Tuple Functions
Using Set Functions