question

Raj More avatar image
Raj More asked

Moving Totals in SSAS

This is how I am creating my moving totals as columns in my cube:

MATTY (Moving Annual Total This Year)

SUM ( { [Time Period].[Month].CURRENTMEMBER.Lag(12) : [Time Period].[Month].CURRENTMEMBER }, [Measures].[MeasureColumnName])

MATLY (Moving Annual Total Last Year)

SUM ( { [Time Period].[Month].CURRENTMEMBER.Lag(24) : [Time Period].[Month].CURRENTMEMBER.Lag(12) }, [Measures].[MeasureColumnName])

How do I do the following?

YTDTY (Year To Date This Year)

YTDLY (Year To Date Last Year - up to same date as today)

ssascubescalculations
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Rob Farley avatar image
Rob Farley answered

There is a YTD function in MDX, which is very useful. However, it only works on hierarchies in a dimension marked as Time that have an attribute which is marked as the type 'Year'. It doesn't work on Financial Year, etc. So PeriodsToDate is often better.

In YTDLT, I'm telling it to take a Year ago in the Calendar hierarchy. In YTDTY, I'm just looking at the periods to date until the CurrentMember (which is default in the PeriodsToDate function).

Try:

YTDTY AS 
SUM(PeriodsToDate([Time Period].[Calendar].[Year]),[Measures].[MeasureColumnName])

YTDLY AS 
SUM(PeriodsToDate([Time Period].[Calendar].[Year], ParallelPeriod([Time Period].[Calendar].[Year])),[Measures].[MeasureColumnName])
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.