共用方式為


使用成員函式

成員函式是傳回成員的多維度運算式 (MDX) 函式。 成員函式,例如 Tuple 函式和 set 函式,對於交涉 Analysis Services 中找到的多維度結構至關重要。

在 MDX 中的許多成員函式中,最重要的是 CurrentMember 函式,用來判斷階層上的目前成員。 下列查詢說明如何使用它,以及 Parent Ancestor Prevmember 函 式:

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]  

另請參閱

函式 (MDX 語法)
使用 Tuple 函式
使用 Set 函式