I've used a Last Month to date measure in my SSAS cube. I found it somewhere in the Internet. And it has been set as the following:
iif (
[Date].[Calendar].currentmember.properties("level_number",Typed)<=2
,null
,
iif (
isempty (ParallelPeriod([Date].[Calendar].[Month],1,[Date].[Calendar].currentmember))
,Aggregate(
{
StrToMember(Ancestor([Date].[Calendar].currentmember,[Date].[Calendar].[Month]).Lag(1).FirstChild.uniquename)
:StrToMember(Ancestor([Date].[Calendar].currentmember,[Date].[Calendar].[Month]).Lag(1).LastChild.uniquename)
},[Measures].[Total actuals Prorata]
)
,SUM(
MTD(
ParallelPeriod([Date].[Calendar].[Month]
,1
,[Date].[Calendar].currentmember
)
),[Measures].[Sales]
)
)
It is working as expected on Month level. Even when I drill down on day level it's working! But my problem is the fact that on July 31st for example, I have #VALUE for my Last Month to Date because there is no 31st of June. And it's the same issue for all the other months with less days from the current. The above function seemed to get rid of this problem in the "iif statements" but it doesn't! My Calendar hierarchy is organised by year, quarter, month, day. Any help please?