Last active
August 29, 2015 14:14
-
-
Save osya/91da5420f2be6896308a to your computer and use it in GitHub Desktop.
Calculating today's date in MDX #MDX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH MEMBER [Measures].[Caption for Today] AS Format(Now(), 'MMMM dd, yyyy') | |
MEMBER [Measures].[Member's Unique Name] AS [Date].[Calendar].CurrentMember.UniqueName | |
MEMBER [Measures].[Key for Today] AS Format(Now(), 'yyyyMMdd') | |
MEMBER [Measures].[Key for Today (AW)] AS '2007' + Right([Measures].[Key for Today], 4) | |
MEMBER [Measures].[Today (string)] AS '[Date].[Calendar].[Date].&[' + [Measures].[Key for Today (AW)] + ']' | |
SET [Today] AS StrToMember( [Measures].[Today (string)], CONSTRAINED ) | |
SET [Yesterday] AS [Today].Item(0).PrevMember | |
SET [This Month] AS [Today].Item(0).Parent | |
SET [Prev Month] AS [This Month].Item(0).PrevMember | |
SET [This Year] AS [Today].Item(0).Parent.Parent.parent.Parent | |
SET [Prev Year] AS [This Year].Item(0).PrevMember | |
SET [This Month Prev Year] AS [This Month].Item(0).Lag(12) | |
SELECT { [Measures].[Caption for Today], [Measures].[Member's Unique Name], [Measures].[Key for Today], [Measures].[Key for Today (AW)], [Measures].[Today (string)] } ON 0, | |
{ [Date].[Calendar].[Date].MEMBERS } ON 1 | |
FROM [Adventure Works] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment