我正在尝试计算我正在检查的数据集之前一年的简单移动平均值。
对于从学期201635
,2016 5a
,2016 5b
开始的学生,我在2016年第35周(2016 1
)为我提供了以下查询。< / p>
WITH
MEMBER [Measures].[LY Enrolments 10 Week SMA] AS
(
[Measures].[Enrolments 10 Week SMA]
,ParallelPeriod
(
[Term Record Creation].[ISO Week Calendar].[ISO Year]
,1
,[Term Record Creation].[ISO Week Calendar].[ISO Week].&[201535]
)
)
SELECT
NON EMPTY
{
[Measures].[Enrolments]
,[Measures].[Enrolments 10 Week SMA]
,[Measures].[LY Enrolments 10 Week SMA]
} ON COLUMNS
,NON EMPTY
{
[Term Enrolments].[Terms].[Term Hierarchy].&[2016]&[5a]
,[Term Enrolments].[Terms].[Term Hierarchy].&[2016]&[5b]
,[Term Enrolments].[Terms].[Term Hierarchy].&[2017]&[1]
} ON ROWS
FROM [Enrolments]
WHERE
(
[Term Enrolments].[Cancelled].&[No]
,[Term Record Creation].[ISO Week Calendar].[ISO Week].&[201635]
);
我还希望将2015年第35周的SMA与2015 5a
,2015 5b
,2016 1
放在一起。这就是我想在会员计算中得到的,但没有任何事情发生。
如何比较年份之间的SMA?我如何与之前一年Term Hierarchy
的成员进行比较?
提前感谢您的帮助。
答案 0 :(得分:0)
请尝试为此[Term Record Creation].[ISO Week Calendar].[ISO Week].&[201535]
更改此[Term Record Creation].[ISO Week Calendar].CURRENTMEMBER
。
希望CURRENTMEMBER
函数能够获取WHERE
子句中指定的周。我会尝试对AdvWrks进行测试,但有些不确定。
WITH
MEMBER [Measures].[LY Enrolments 10 Week SMA] AS
(
[Measures].[Enrolments 10 Week SMA]
,ParallelPeriod
(
[Term Record Creation].[ISO Week Calendar].[ISO Year]
,1
,[Term Record Creation].[ISO Week Calendar].CURRENTMEMBER
)
)
SELECT
NON EMPTY
{
[Measures].[Enrolments]
,[Measures].[Enrolments 10 Week SMA]
,[Measures].[LY Enrolments 10 Week SMA]
} ON COLUMNS
,NON EMPTY
{
[Term Enrolments].[Terms].[Term Hierarchy].&[2016]&[5a]
,[Term Enrolments].[Terms].[Term Hierarchy].&[2016]&[5b]
,[Term Enrolments].[Terms].[Term Hierarchy].&[2017]&[1]
} ON ROWS
FROM [Enrolments]
WHERE
(
[Term Enrolments].[Cancelled].&[No]
,[Term Record Creation].[ISO Week Calendar].[ISO Week].&[201635]
);
经过测试,这对我有用:
WITH
MEMBER [Measures].[Internet Sales Amount LY] AS
(
[Measures].[Internet Sales Amount]
,[Date].[Calendar Weeks].[Calendar Week].&[27]&[2007]
)
MEMBER [Measures].[Internet Sales Amount LY2] AS
(
[Measures].[Internet Sales Amount]
,ParallelPeriod
(
[Date].[Calendar Weeks].[Calendar Year]
,1
,[Date].[Calendar Weeks].CurrentMember
)
)
SELECT
NON EMPTY
{
[Measures].[Internet Sales Amount LY]
,[Measures].[Internet Sales Amount LY2]
,[Measures].[Internet Sales Amount]
} ON COLUMNS
,NON EMPTY
{
[Product].[Product Categories].[Category].[Accessories]
,[Product].[Product Categories].[Category].[Bikes]
,[Product].[Product Categories].[Category].[Clothing]
} ON ROWS
FROM [Adventure Works]
WHERE
[Date].[Calendar Weeks].[Calendar Week].&[27]&[2008];
结果如下: