我有以下MDX:
SELECT
NON EMPTY
{
[Measures].[Returns]
,[Measures].[Returns]
} ON COLUMNS
,NON EMPTY
{[Employees].[Company].[Company].ALLMEMBERS}
DIMENSION PROPERTIES
MEMBER_CAPTION
,MEMBER_UNIQUE_NAME
ON ROWS
FROM
(
SELECT
StrToSet
("[Exec Date].[Hierarchy].[Month Num].&[2014]&[1]"
,CONSTRAINED
) ON COLUMNS
FROM [cbSales]
)
WHERE
IIF
(
StrToSet
("[Exec Date].[Hierarchy].[Month Num].&[2014]&[1]"
,CONSTRAINED
).Count
= 1
,StrToSet
("[Exec Date].[Hierarchy].[Month Num].&[2014]&[1]"
,CONSTRAINED
)
,[Exec Date].[Hierarchy].CurrentMember
);
两列都显示2014/01月的返回数据
我想在第二栏中提供下个月(2014/02)的数据。
如何更改查询以实现目标。
答案 0 :(得分:0)
我将尝试使用AdvWks多维数据集进行复制,因此目前尚未测试:
WITH
MEMBER [Measures].[ReturnsNextMth] AS
(
[Measures].[Returns]
,[Exec Date].[Hierarchy].CurrentMember.NextMember
)
SELECT
NON EMPTY
{
[Measures].[Returns]
,[Measures].[ReturnsNextMth]
} ON COLUMNS
,NON EMPTY
{
[Employees].[Company].[Company].ALLMEMBERS
*
[Exec Date].[Hierarchy].[Month Num].ALLMEMBERS
} ON ROWS
FROM
(
SELECT
StrToSet
("[Exec Date].[Hierarchy].[Month Num].&[2014]&[1]"
,CONSTRAINED
) ON COLUMNS
FROM [cbSales]
);
AdvWks中的类似内容:
WITH
MEMBER [Measures].[ReturnsNextMth] AS
(
[Measures].[Internet Order Count]
,[Date].[Calendar].CurrentMember.NextMember
)
SELECT
NON EMPTY
{
[Measures].[Internet Order Count]
,[Measures].[ReturnsNextMth]
} ON COLUMNS
,NON EMPTY
{
[Sales Territory].[Sales Territory].[Country].MEMBERS
*
[Date].[Calendar].[Month].ALLMEMBERS
} ON ROWS
FROM
(
SELECT
[Date].[Calendar].[Month].&[2008]&[1] ON COLUMNS
FROM [Adventure Works]
);
这给出了这些结果。我发现这非常令人惊讶,因为子选择似乎表明我们只有2008年1月可用,但是亚选择是一个奇怪的生物。本文解释:http://bisherryli.com/2013/02/08/mdx-25-slicer-or-sub-cube/。所以我们的衡量标准[ReturnsNextMth]
仍可正常运作。