在MDX中合并两个子选择

时间:2019-02-14 16:21:26

标签: subquery ssas mdx

我有两个具有共同成员的查询:行和列:

WITH 
MEMBER [Measures].[AliasMeasure1] as [Measures].[F],format_string='#,0' 
MEMBER [Measures].[AliasMeasure2] as SUM({ParallelPeriod([Time].[E].[Year],1,[Time].[E].[Year].&[2018]) : ParallelPeriod([Time].[E].[Year],1,[Time].[E].[Year].&[2018])},[Measures].[AliasMeasure1])
MEMBER [Measures].[Growth] as ([Measures].[AliasMeasure1]-[Measures].[AliasMeasure2])/ABS( [Measures].[AliasMeasure2] ),format_string='#,0.00%'  

Select 
{FILTER({NONEMPTY([RegionGlobal].[Region].[Total]) *[Area].[SDR].[Total],
NONEMPTY([RegionGlobal].[Region].CHILDREN - [RegionGlobal].[Region].&[MD]) *[Area].[SDR].CHILDREN},
NOT ISEMPTY([Measures].[AliasMeasure1])) *{[Measures].[AliasMeasure1],
[Measures].[Growth]}} on columns, 

FILTER([CP].[PDR].MEMBERS,NOT ISEMPTY([Measures].[AliasMeasure1])) on rows  

其中一个查询具有此子选择:

FROM ( 
SELECT 
{[Time].[E].[Year].&[2018]:[Time].[E].[Year].&[2018]} on 0,
{[RegionGlobal].[Region].[Total]} on 1,
{[Area].[Area].[Total]} on 2,
{[Global_LI].[isLI].&[1]} on 3 FROM CUBE )

第二个查询非常相似:

FROM ( 
SELECT 
{[Time].[E].[Year].&[2018]:[Time].[E].[Year].&[2018]} on 0,
{[RegionGlobal].[Region].&[USA]} on 1,
{[Area].[Area].&[AUSA]} on 2 FROM CUBE )

如何将其合并为一个查询?我尝试创建“位置”,但是尺寸不同。

预先感谢

1 个答案:

答案 0 :(得分:2)

您的子选择具有不同的层次结构和维度。我在下面的查询中平衡了它们。您可以将其用作子选择

    SELECT 
{[Time].[E].[Year].&[2018]:[Time].[E].[Year].&[2018]} on 0,
{
([RegionGlobal].[Region].[Total],[Area].[Area].[Total],[Global_LI].[isLI].&[1]),
([RegionGlobal].[Region].&[USA],[Area].[Area].&[AUSA],[Global_LI].[isLI].defaultmember)
}
 on 1
FROM CUBE