组合2个mdx查询

组合2个mdx查询,mdx,olap,Mdx,Olap,我有两个来自同一个多维数据集的MDX查询。两者使用相同的度量值,但具有不同的时间集(两个时间集的维度相同,但层次结构不同) 我希望将它们合并到同一个表结果中,因此它将显示两个度量(由不同的集合切割)和另一个时间维度(“星期几”),该维度也使用相同的时间维度。 查询可以单独运行,如下所示: with member [Measures].[AVG_6_WEEKS] as [Measures].[Number of Answered Comms] /6 select

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

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

   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.

以下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
函数将上下文从查询中的子选择移动到了成员定义中。

谢谢,弗兰克,但是使用此脚本会导致结果表中出现错误:聚合函数不能用于度量维度中的计算成员。