For starters, make sure you have created the proper date dimensions with at the minimum (for best effect) a date and year column. Yes, this seems obviously but still it needs to be said. Now that we have that out of the way, the steps are as follows:
- Add Calendar hierarchy (Works best this way)
- Make sure Date Dimension is specified as Time in Dimension Properties
- Add Attribute Relationships (see my previous blog post on this)
AGGREGATE
(
PERIODSTODATE
(
[Dim Date].[Calendar].[Year],
[Dim Date].[Calendar].CurrentMember
),
([Measures].[Amount])
)
In my example I have a Date hierarchy called DimDate. In the above code, I used called this Measure YTD, not using that same calculation, I added it to a ParalellPeriod function to get the Previous year. The code is as follows:
SUM
(
ParallelPeriod
([Dim Date].[Calendar].[Year],
1,
[Dim Date].[Calendar].CurrentMember),[Measures].[YTD]
)
This should work as long as you have process the YTD measure and then created the Previous YTD calculation. Also, this requires the Measure to be aligned with an Year filter (you will see NULLs otherwise) to work.
Again, a common calculation but commonly done incorrectly. Hopefully this helps you.