结合2个mdx查询

时间:2014-11-03 09:35:36

标签: mdx olap

我有来自同一个多维数据集的2个MDX查询。两者都使用相同的度量,但具有不同的时间集(时间集都是相同的维度但不同的层次结构)。

我希望将它们加入到相同的表结果中,因此它将呈现2个度量(由不同集合切割)和另一个时间维度(“星期几”),它们也使用相同的时间维度。 查询可以单独运行,如下所示:

   with member [Measures].[AVG_6_WEEKS] as 
     [Measures].[Number of Answered Comms] /6
    select 
    nonempty([Comm Date UTC].[Day of Week].children)
    on 0, 
    [Measures].[AVG_6_WEEKS]
    on 1 
    from (select {LASTPERIODS( 42,[Comm Date UTC].[Year Month Day].lastsibling.lastchild.lastchild.lastchild.prevmember )}
    on 0 from comms)

;
 with member [Measures].[Answered Comms] as 
 [Measures].[Number of Answered Comms] 
select 
nonempty([Comm Date UTC].[Day of Week].children)
on 0, 
[Measures].[Answered Comms]
on 1 
from (select {LASTPERIODS( 7,[Comm Date UTC].[Year Month 
Day].lastsibling.lastchild.lastchild.lastchild.prevmember )}
    on 0 from comms)

可以吗?我总是得到一个错误,我不能在查询中使用相同的时间层次结构... 任何的想法?像SQL这样的东西我可以加入2个视图吗?

谢谢

号Yoni。

1 个答案:

答案 0 :(得分:0)

以下MDX应该这样做:

with member [Measures].[AVG_6_WEEKS] as 
     Aggregate({LASTPERIODS( 42,[Comm Date UTC].[Year Month Day].lastsibling.lastchild.lastchild.lastchild.prevmember )},
               [Measures].[Number of Answered Comms] /6
              )
     member [Measures].[Answered Comms] as 
     Aggregate({LASTPERIODS( 7,[Comm Date UTC].[Year Month Day].lastsibling.lastchild.lastchild.lastchild.prevmember )},
               [Measures].[Number of Answered Comms]
              ) 
select 
nonempty([Comm Date UTC].[Day of Week].children)
on 0, 
{ [Measures].[AVG_6_WEEKS], [Measures].[Answered Comms] }
on 1 
from comms

我使用Aggregate函数将查询中的子选择的上下文移动到成员定义。