SET
How to find the last 52 weeks data based on current week as the end week in MDX?
There are two ways to achieve this:
First using Lag(
Last52Weeks AS
{STRTOMEMBER("[Date].[Calendar Week of Year].&[25]", CONSTRAINED).Lag(51):STRTOMEMBER("[Date].[Calendar Week of Year].&[25]", CONSTRAINED)}
SELECT {
[Measures].[Internet Sales Amount]
} ON 0,
NON EMPTY {
Last52Weeks
} ON 1
FROM [Adventure Works]
Second way of achieving this using LastPeriods(
SELECT Tail([Time].[Fiscal YWD].[WEEK].MEMBERS,1) ON 1
, NULL ON 0 FROM PROFITBASE
WHERE
LASTPERIODS(365,STRTOMEMBER(@CurrentDay,CONSTRAINED))
No comments:
Post a Comment