You may use ClosingPeriod function to do that:
ClosingPeriod
(
[Dim Date].[Date Hierarchy].[Month]
,[Dim Date].[Date Hierarchy].CurrentMember
)
will give you the closing month based on the CurrentMember
Let’s say we have data up to May 2011 date, the above function will return MAY for 2011 and DECEMBER for the prior years.
If you are looking for last non empty member, you may use the following:
Tail
(
NonEmpty
(
[Dim Date].[Date Hierarchy].[Date].MEMBERS
,{[Measures].[measureX]}
)
,1
).Item(0)