MDX:如何结合两个维度的结果?

时间:2012-08-17 14:32:46

标签: mdx

我是MDX的新手。现在我想结合两个不同维度的两个结果。我正在使用以下代码:

With 
 MEMBER [Measures].[Student Head Count].[Program1] AS
([Program1].[Program1].&[1])
MEMBER [Measures].[Student Head Count].[Program2] AS
([Program2].[Program2].&[1]) 

SELECT
NON EMPTY
{
[Measures].[Student Head Count].[Program1] ,
[Measures].[Student Head Count].[Program2]
}
ON COLUMNS

FROM [Current Student Overview]

错误显示:

The Program1 calculated member cannot be created because its parent is at the lowest level in the Measures hierarchy.

我知道“学生人数”处于最低级别,但我不知道如何修改语法。如果我用“测试”替换“学生人数”,它也不起作用。此外,“联盟”不起作用,因为我尝试。任何人都可以帮我修改或新的MDX吗?

我尝试使用以下脚本使用Crossjoin:

SELECT
 NON EMPTY
{

 [Measures].[Student Head Count]
}
ON COLUMNS,
NON EMPTY
{
NONEMPTYCROSSJOIN({[Program1].[Program1].&[1]},{[Program2].[Program2] }),
NONEMPTYCROSSJOIN({[Program1].[Program1] },{[Program2].[Program2].&[1]})  
}
on 1


FROM [Current Student Overview]

结果是:

enter image description here

我怎样才能消除或隐藏performancepoint中的“All”列?

1 个答案:

答案 0 :(得分:2)

“测量”维度上只有一个级别。您的度量名称应为[Measures].[Program21][Measures].[Program2]

你也可以像这样重写你的查询:

SELECT
NON EMPTY
{
    ([Program1].[Program1].&[1], [Program2].[Program2].&[1])
}
ON COLUMNS
FROM [Current Student Overview]
WHERE ([Measures].[Student Head Count])

在Mdx中,您无法结合不同维度的结果,但您可以使用CrossJoin函数执行交叉产品。

编辑: 当您的集合中只有一个成员时,您不需要使用CrossJoin。你可以(member1, member2)

如果您不想看到All,可以使用类似这样的查询:

WITH
 MEMBER [Measures].[Student Head Count Program1] AS
    ([Measures].[Student Head Count], [Program1].[Program1].&[1], [Program2].[Program2].[All])
MEMBER [Measures].[Student Head Count Program2] AS
    ([Measures].[Student Head Count], [Program1].[Program1].[All], [Program2].[Program2].&[1]) 
SELECT
NON EMPTY
{
    [Measures].[Student Head Count Program1] ,
    [Measures].[Student Head Count Program2]
}
ON COLUMNS
FROM [Current Student Overview]