04 September 2008

MDX-How do you get Last month in the time dimension

Q: How do you get Last month in the time dimension?

A: You can use function ClosingPeriod( [ Level_Expression [ ,Member_Expression ] ] )

Example (here we assume that default member is [All]):

SELECT ClosingPeriod([Date].[Calendar].[Month], [Date].[Calendar].DefaultMember) ON 0
FROM [Sales Summary]
WHERE ([Measures].[Sales Amount])