在 SSAS 中,跨月和年时无法使 ParallelPeriod 函数起作用
我正在 Analysis Services 2008R2 中针对 Adventure Works 多维数据集构建 MDX 请求。我想要在行中获取月份,在列中获取年份,以便结果看起来像:
2005 | 2006 | 2007 | ...
January ... | ... | ... | ...
February ... | ... | ... | ...
March ... | ... | ... | ...
...
以下请求工作正常:
SELECT
[Date].[Month of Year].CHILDREN ON ROWS,
( [Date].[Calendar Year].CHILDREN, { [Measures].[Sales Amount] } ) ON COLUMNS
FROM [Adventure Works]
现在,我想将当月的销售额与上个月的销售额进行比较:
2005 || 2006 || ...
Sales | Sales prev month || Sales | Sales prev month ||...
January ... | ... || ... | ... || ...
February ... | ... || ... | ... || ...
March ... | ... || ... | ... || ...
...
我使用以下命令编写了一个请求ParallelPeriod 函数:
WITH MEMBER [Sales Amount Prev Month] AS ([Measures].[Sales Amount], ParallelPeriod([Date].[Calendar].[Month], 1))
SELECT
[Date].[Month of Year].CHILDREN ON ROWS,
( [Date].[Calendar Year].CHILDREN, { [Measures].[Sales Amount], [Sales Amount Prev Month] } ) ON COLUMNS
FROM [Adventure Works]
问题是我得到的 [Sales Amount Prev Month] 度量值为 NULL。
看起来,尽管每个单元格代表一个月和一年,SSAS 似乎无法确定当前的 [日期].[日历].[月] 成员。然后,ParallelPeriod 无法获取上个月。
关于如何使 ParallelPeriod 函数在这种情况下工作有什么想法吗?非常感谢。
I am building an MDX request against the Adventure Works cube in Analysis Services 2008R2. I want to get months in rows and years in columns so that the result looks like:
2005 | 2006 | 2007 | ...
January ... | ... | ... | ...
February ... | ... | ... | ...
March ... | ... | ... | ...
...
The following request works fine:
SELECT
[Date].[Month of Year].CHILDREN ON ROWS,
( [Date].[Calendar Year].CHILDREN, { [Measures].[Sales Amount] } ) ON COLUMNS
FROM [Adventure Works]
Now, I would like to compare the sales of the current month with the sales of the previous month:
2005 || 2006 || ...
Sales | Sales prev month || Sales | Sales prev month ||...
January ... | ... || ... | ... || ...
February ... | ... || ... | ... || ...
March ... | ... || ... | ... || ...
...
I wrote a request using the ParallelPeriod function:
WITH MEMBER [Sales Amount Prev Month] AS ([Measures].[Sales Amount], ParallelPeriod([Date].[Calendar].[Month], 1))
SELECT
[Date].[Month of Year].CHILDREN ON ROWS,
( [Date].[Calendar Year].CHILDREN, { [Measures].[Sales Amount], [Sales Amount Prev Month] } ) ON COLUMNS
FROM [Adventure Works]
The issue is that I get NULL values for the [Sales Amount Prev Month] measure.
It looks like, in spite of the fact that each cell represents a month and year, SSAS does not seem to be able to determine the current [Date].[Calendar].[Month] member. Then, the ParallelPeriod does not manage to get the previous month.
Any idea on how to make the ParallelPeriod function work in that case? Many thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我收到了来自 Microsoft 的以下 MDX 查询:
它相当复杂,但似乎解决了问题。
I received the following MDX query from Microsoft:
It's quite complex but it seems to solve the issue.
怎么样:
当您想要上一季度的相应月份时,可以使用平行期间。这里 PrevMember 应该足够了。
更新:根据您的评论,我尝试利用另一个解决方案已经存在的层次结构:
What about:
Parallel period is used when you want the corresponding month in the previous quarter. Here PrevMember should be enough.
Update: following your comment I tried to exploit the hierarchies already present with another solution: