1

这个元组为我提供了维度 X 的度量 X 的聚合[MyHierarchy].[MyHierarchy].&[some_value]

([Measures].[X], [MyHierarchy].[MyHierarchy].&[some_value]) 

但是什么是补充 - 即同一层次结构中的Measures.X,但不包括 [MyHierarchy].[MyHierarchy].&[some_value]

我确定这是 EXCEPT 函数,但我似乎无法正确使用语法。

4

2 回答 2

2

聚合任何类型的集合的一般想法是:

with member [Measures].[Y] as 
       aggregate( 
         except( [hierarchy].members, { excluded } ), 
         [Measures].[X] )
       )

Aggregate() 正在处理 [Measures] 的任何实际聚合。问题是,如果 [hierarchy].members 包含一些中间(父)成员,那么您的值将被计算两次。

如果聚合是 SUM 并且您有一个all成员,那么下面给出了预期的结果:

with member [Measures].[Y] as 
       ( [hierarchy].[all], [Measures].[X] ) 
       - sum( { excluded }, [Measures].[X] )

如果不是全部,那么您可以使用第一级的成员:

with member [Measures].[Y] as 
       sum( [hierarchy].levels(0), [Measures].[X] ) 
       - sum( { excluded }, [Measures].[X] )

_

于 2012-08-13T03:35:15.637 回答
1

以下表达式适用于非线性聚合函数:

WITH MEMBER [Measures].[Y] as 
       Aggregate( 
         Except( [MyHierarchy].[MyHierarchy].&[some_value].Level.Members, { [MyHierarchy].[MyHierarchy].&[some_value] } ), 
         [Measures].[X] )
       )

当您必须排除属于同一级别的多个成员(排除的成员在excludedMembers集合中)时,您可以对其进行概括:

WITH MEMBER [Measures].[Y] as 
       Aggregate( 
         Except( excludedMembers.Item(0).Level.Members , excludedMembers ), 
         [Measures].[X] )
       )
于 2012-08-13T06:25:43.353 回答