这个元组在[MyHierarchy].[MyHierarchy].&[some_value]
维度中得到了度量X的集合。
([Measures].[X], [MyHierarchy].[MyHierarchy].&[some_value])
但补充是什么 - 即同一层次结构中的Measures.X 但不包括 [MyHierarchy].[MyHierarchy].&[some_value]
我确定它是EXCEPT函数,但我似乎无法正确使用语法。
答案 0 :(得分:2)
聚合任何类型的集合的一般想法是:
with member [Measures].[Y] as
aggregate(
except( [hierarchy].members, { excluded } ),
[Measures].[X] )
)
Aggregate()正在处理[Measures]的任何实际聚合。问题是,如果[hierarchy] .members包含一些中间(父)成员,那么您将计算两次值。
如果聚合是SUM并且您拥有所有成员,那么以下内容将给出预期结果:
with member [Measures].[Y] as
( [hierarchy].[all], [Measures].[X] )
- sum( { excluded }, [Measures].[X] )
如果没有 all ,则可以使用第一级成员:
with member [Measures].[Y] as
sum( [hierarchy].levels(0), [Measures].[X] )
- sum( { excluded }, [Measures].[X] )
_
答案 1 :(得分: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] )
)