我正在尝试使用SSAS 2014中的MDX计算移动平均线,但所有结果都出来了(null)。
阅读多个网络参考和博客文章让我觉得这应该有效,给出3个月的移动平均线:
With
MEMBER [Measures].[MA3] AS
Avg(
[Date].[Calendar Years].[Month].CurrentMember.Lag(2)
: [Date].[Calendar Years].[Month],
[Measures].[Project Views]
)
SELECT { [Measures].[Project Views], [Measures].[MA3] } ON 0,
[Date].[Calendar Years].[Month] ON 1
FROM [ProjectAccesses]
但是,每列中都会显示(null)。
我希望在每种情况下使用以下成员的数量为3:
MEMBER [Measures].[C3] AS
Count(
[Date].[Calendar Years].[Month].CurrentMember.Lag(2)
: [Date].[Calendar Years].[Month],
INCLUDEEMPTY
)
但同样,没有检测到语法错误但是所有值都是(null),这让我相信月份范围集可能是空的。
我已经在这里待了好几个小时了,并且已经没有什么东西可以尝试了。
任何人都可以建议可能出现的问题;我是MDX的新手,因此可能是我的查询结构错误或我的多维数据集配置中出现了一些我无法找到的错误。
由于
答案 0 :(得分:1)
我相信你需要改变
": [Date].[Calendar Years].[Month],"
要
": [Date].[Calendar Years].currentmember,"
[日期]。[日历年]。[月] - >应该给出水平,而不是你想要的当前成员
答案 1 :(得分:0)
我找到了解决方案。我原以为我需要根据我的[Calendar Years]层次结构中的成员来构建我的集合。但是,如果没有层次结构,下面的工作正常(虽然我无法解释为什么原始版本没有)。
With
MEMBER [Measures].[MA3] AS
Avg(
[Date].[Month].CurrentMember.Lag(2)
: [Date].[Month].CurrentMember,
[Measures].[Project Views]
)
MEMBER [Measures].[C3] AS
Count(
[Date].[Month].CurrentMember.Lag(2)
: [Date].[Month].CurrentMember,
INCLUDEEMPTY
)
SELECT { [Measures].[Project Views], [Measures].[MA3] , [Measures].[C3] } ON 0,
[Date].[Calendar Years].[Month] ON 1
FROM [ProjectAccesses]
答案 2 :(得分:0)
我很惊讶你无法使用Calendar Years层次结构。我添加了一些额外的诊断措施,以便您可以看到当前成员函数返回的内容:
WITH
MEMBER [Measures].[MA3] AS
AVG(
[Date].[Calendar Years].CurrentMember.Lag(2)
: [Date].[Calendar Years].CurrentMember,
[Measures].[Project Views]
)
MEMBER [Measures].[C3] AS
COUNT(
[Date].[Calendar Years].CurrentMember.Lag(2)
: [Date].[Calendar Years].CurrentMember,
INCLUDEEMPTY
)
MEMBER [Measures].[Diagn1] AS
[Date].[Calendar Years].CurrentMember.member_caption
MEMBER [Measures].[Diagn2] AS
[Date].[Calendar Years].CurrentMember.Lag(2).member_caption
SELECT
{
[Measures].[Project Views]
, [Measures].[MA3]
, [Measures].[C3]
, [Measures].[Diagn1]
, [Measures].[Diagn2]
} ON 0,
[Date].[Calendar Years].[Month].MEMBERS ON 1
FROM [ProjectAccesses];