4

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

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.

我知道“Student Head Count”处于最低级别,但我不知道如何修改语法。如果我将“Student Head Count”替换为“Test”,它也不起作用。此外,我尝试过的“联合”不起作用。任何人都可以帮助我修改或新的 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]

结果是:

在此处输入图像描述

那么如何消除或隐藏性能点中的“全部”列?

4

1 回答 1

2

Measure 维度上只有一个级别。您的度量名称应该是[Measures].[Program21]and [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]
于 2012-08-17T15:01:34.623 回答