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)

more ▼

asked Oct 27, 2009 at 03:38 PM in Default

avatar image

Raj More
1.8k 83 89 90

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

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).


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])

more ▼

answered Oct 27, 2009 at 08:40 PM

avatar image

Rob Farley
5.8k 16 22 28

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Oct 27, 2009 at 03:38 PM

Seen: 2710 times

Last Updated: Oct 27, 2009 at 03:38 PM

Copyright 2018 Redgate Software. Privacy Policy