【发布时间】:2017-08-15 21:26:58
【问题描述】:
我在 Adventure Works 中玩弄 MDX。我尝试不同的事情来练习(所以我知道可能有更好的方法来使用日期层次结构来实现这一点,但我正在尝试使用月份名称而不是特定的月份和年份名称(如果这有意义的话). 我想要做的是使用一个 case 语句,它会滞后于我的 2 个集合,但不会滞后于其他 2 个。换句话说,我希望它返回 2010 年第一季度的值(7 月,8 月,Sept) 和 Q2 (Oct, Nov, Dec) 设置,但 2011 年 Q3(Jan,Feb,Mar) 和 Q4 设置 (Apr, May, June) 的值。这就是我所拥有的,但案例陈述只是给出了滞后1 为所有。所以我理解它是如何工作的,但我似乎无法理解如何为每个集合返回不同的值,如上所述。
WITH
SET [Q1 Combined] AS {
[Date].[Month of Year].&[7],
[Date].[Month of Year].&[8],
[Date].[Month of Year].&[9] }
SET [Q2 Combined] AS {
[Date].[Month of Year].&[10],
[Date].[Month of Year].&[11],
[Date].[Month of Year].&[12] }
SET [Q3 Combined] AS {
[Date].[Month of Year].&[1],
[Date].[Month of Year].&[2],
[Date].[Month of Year].&[3] }
SET [Q4 Combined] AS {
[Date].[Month of Year].&[4],
[Date].[Month of Year].&[5],
[Date].[Month of Year].&[6] }
MEMBER [Date].[Month of Year].[FY Q1 Fix] AS Aggregate([Q1 Combined])
MEMBER [Date].[Month of Year].[FY Q2 Fix] AS Aggregate([Q2 Combined])
MEMBER [Date].[Month of Year].[FY Q3 Fix] AS Aggregate([Q3 Combined])
MEMBER [Date].[Month of Year].[FY Q4 Fix] AS Aggregate([Q4 Combined])
SELECT
[Measures].[Internet Sales Amount] ON COLUMNS,
{
[Date].[Month of Year].[FY Q1 Fix],
[Date].[Month of Year].[FY Q2 Fix],
[Date].[Month of Year].[FY Q3 Fix],
[Date].[Month of Year].[FY Q4 Fix]} ON ROWS
} ON ROWS
FROM [Adventure Works]
WHERE **I WANT TWO DIFFERENT SLICES**
也就是说,我想要:
[FY Q1 Fix] 和 [FY Q2 Fix] 被切片并显示 [Date].[2010]措施
[FY Q3 Fix] 和 [FY Q4 Fix] 切片并显示 [Date]。[2011]措施
【问题讨论】:
标签: case where mdx adventureworks