使用邏輯函式
邏輯函式會對物件和運算式執行邏輯作業或比較,並傳回布林值。 邏輯函式在多維度運算式中很重要,以判斷成員的位置。
最常使用的邏輯函式是 IsEmpty 函式。 如需如何使用 IsEmpty 函式的詳細資訊,請參閱 使用空白值 。
下列查詢示範如何使用 IsLeaf 和 IsAncestor 函式:
WITH
//Returns true if the CurrentMember on Calendar is a leaf member, ie it has no children
MEMBER MEASURES.[IsLeafDemo] AS IsLeaf([Date].[Calendar].CurrentMember)
//Returns true if the CurrentMember on Calendar is an Ancestor of July 1st 2001
MEMBER MEASURES.[IsAncestorDemo] AS IsAncestor([Date].[Calendar].CurrentMember, [Date].[Calendar].[Date].&[1])
SELECT{MEASURES.[IsLeafDemo],MEASURES.[IsAncestorDemo] } ON 0,
[Date].[Calendar].MEMBERS ON 1
FROM [Adventure Works]