Použití členských funkcí

Členová funkce je funkce Multidimensional Expressions (MDX), která vrací člen. Členské funkce, jako jsou n-ticové a množinové funkce, jsou nezbytné pro vyjednávání s vícerozměrnými strukturami v analytických službách.

Z mnoha členských funkcí v MDX je nejdůležitější funkce CurrentMember , která slouží k určení aktuálního člena v hierarchii. Následující dotaz ilustruje, jak jej používat spolu s funkcemi Rodič,Předek a Předchozí člen :

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]