我有以下工作代码:
WITH
SET NewIDs AS
INTERSECT(NonEmpty([ID].Children, CROSSJOIN([Date].&[T-1], [Category].&[Old]))
, NonEmpty([ID].Children, CROSSJOIN([Date].&[T], [Category].&[EOD]))
)
SELECT
NON EMPTY([Dim2].Children
) ON 0
,
NON EMPTY([NewIDs]
) ON 1
FROM [MyCube]
WHERE [Measures].[Value]
但是我希望在行上有另一个维度,而不是ID(让我们称之为Dim1)
我已尝试过以下内容,但它不起作用(因为我不认为你可以在命名集上切片)
WITH
SET NewIDs AS
INTERSECT(NonEmpty([ID].Children, CROSSJOIN([Date].&[T-1], [Category].&[Old]))
, NonEmpty([ID].Children, CROSSJOIN([Date].&[T], [Category].&[EOD]))
)
SELECT
NON EMPTY([Dim2].Children
) ON 0
,
NON EMPTY([Dim1].Children
) ON 1
FROM [MyCube]
WHERE [Measures].[Value]
, [NewIDs]
编辑: 进一步清晰。我通常聚合Value度量,并在Dim2的列表和行Dim1表中查看(这将包括所有 ID)。但是现在我想要这个,但只在[NewIDs]集上切片。
EDIT2: 使用下面的代码几乎解决了我的问题,但在行上我有一个不需要的列,其中每个值都是 NewIDs ,理想情况下我不希望这样。
WITH
SET NewIDs AS
INTERSECT(NonEmpty([ID].Children, CROSSJOIN([Date].&[T-1], [Category].&[Old]))
, NonEmpty([ID].Children, CROSSJOIN([Date].&[T], [Category].&[EOD]))
)
MEMBER [ID].[NewIDs] AS
Aggregate([NewIDs])
SELECT
NON EMPTY([Dim2].Children
) ON 0
,
NON EMPTY([ID].[NewIDs] * [Dim1].Children
) ON 1
FROM [MyCube]
WHERE [Measures].[Value]
答案 0 :(得分:0)
如果在添加到WHERE子句之前进行聚合,是否会出现错误?
WITH
SET [NewIDs] AS
INTERSECT(
NonEmpty(
[ID].Children,
([Date].&[T-1], [Category].&[Old])
)
, NonEmpty(
[ID].Children,
([Date].&[T], [Category].&[EOD])
)
)
MEMBER [ID].[All].NewIDs AS
AGGREGATE( [NewIDs] )
SELECT
NON EMPTY([Dim2].Children
) ON 0
,
NON EMPTY([Dim1].Children
) ON 1
FROM [MyCube]
WHERE
( [Measures].[Value]
, [ID].[All].NewIDs );
尝试将整个表达式放入WHERE子句:
SELECT
NON EMPTY([Dim2].Children) ON 0
,NON EMPTY([Dim1].Children) ON 1
FROM [MyCube]
WHERE
( [Measures].[Value]
, AGGREGATE(
INTERSECT(
NonEmpty(
[ID].Children,
([Date].&[T-1], [Category].&[Old])
)
, NonEmpty(
[ID].Children,
([Date].&[T], [Category].&[EOD])
)
)
)
);