成员函数是一种多维表达式(MDX)函数,用于返回成员。 成员函数,如元组函数和集合函数,对于协商分析服务中的多维结构至关重要。
在MDX中的众多成员函数中,最重要的是 CurrentMember 函数,用于确定层级结构中的当前成员。 以下查询展示了如何使用它,以及父函数、祖先函数和前成员函数:
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]