YTD, MTD etc for Current Point In Time

I've set up time intelligence on my cube. This works fine. I can get to:

YTDYTD Prior YearYTD Index
Jun 2006 Qtr502962467145107.6672125
Sep 2006 Qtr73339691614480.05248083
Dec 2006 Qtr733396144086850.89959663
Mar 2007 Qtr733396185059539.63028107

with the following MDX.

SELECT { [Time Calculations].[YTD], [Time Calculations].[YTD Prior Year], [Time Calculations].[YTD Index] } ON COLUMNS ,

{ [Time].[Fiscal Hierarchy].[Fiscal Year].&[2007].CHILDREN } ON ROWS

FROM [mycube]

WHERE ( [Measures].[Order Quantity] )

This works fine if I have time series on rows and time calculations as columns. What I want to be able to do is display YTD / MTD as of now (I have an attribute which flags today's date). I'd also like YTD prior year to equal up to including the equivalent date last year. These would appear as columns and then I would have data from other dimensions displayed on rows. Something like this:

MTDMTD Prior YearYTDYTD Prior Year
Product 112811810501415
Product 2111214
Product 312925646554
Product 4453792445

To get this to work do I need to amend my MDX or do I need to change the structure of my cube? Could somebody tell me the best way of achieving this? Thanks.

[11295 byte] By [mamo] at [2007-12-25]
# 1

Have you tried to add a time slicer to the MDX? In WHERE ( [Measures].[Order Quantity]) you add WHERE ( [Measures].[Order Quantity] ,[Time].[Hiearchy].&[Year].&[Month].&[Day]).?

Regards

Thomas Ivarsson

ThomasIvarsson at 2007-9-3 > top of Msdn Tech,SQL Server,SQL Server Analysis Services...
# 2

Thomas

I probably haven't explained what I'm trying to achieve that well. I don't think your response answers my query. In order to achieve what I need, my cube needs to understand what the current date is. I don't want to be substituting values within my mdx statement (ie year = 2007, period = 6 etc).

In AS2000 I had custom rollup expressions that I used to give me fixed ytd, mtd (as of latest cube update). I think I can probably achieve the same thing using Time Calculations (although my mdx writing skills aren't the best!). I just wondered whether there was an recommended way of structuring my cube in order to achieve this?

Mark

mamo at 2007-9-3 > top of Msdn Tech,SQL Server,SQL Server Analysis Services...
# 3

OK. You would like dynamic time members that points to the latest date?

This is an example of how I have done it with a normal time dimension with one calendar hierarchy.

Tail(Filter([Time].[Time_Calendar].[Month].Members,(Time.[Time_Calendar].Currentmember,[Measures].[MyMeasure])>0))

The logic here is that to use a measure like actual sales that you know will give you a point of reference in time.

There are several other ways to solve this.

HTH

Thomas Ivarsson

ThomasIvarsson at 2007-9-3 > top of Msdn Tech,SQL Server,SQL Server Analysis Services...
# 4

I can get:

PeriodsToDate([Time].[Fiscal Hierarchy].[Fiscal Year],Filter([Time].[Fiscal Hierarchy].[Fiscal Period].members,[Time].[Fiscal Period Current].[1] ).item(0))

to work as a set.

However if I create a member:

Aggregate(PeriodsToDate([Time].[Fiscal Hierarchy].[Fiscal Year],Filter([Time].[Fiscal Hierarchy].[Fiscal Period].members,[Time].[Fiscal Period Current].[1] ).item(0)))

it doesn't return anything. Is there anything I need to do to get it to apply to all or particular measures? Thanks.

Mark

mamo at 2007-9-3 > top of Msdn Tech,SQL Server,SQL Server Analysis Services...
# 5

In my previous example you use that MDX to build a set and call that CurrentMonth. It is as easy to change to CurrentDay.

With this set you can start building other named sets refering to this named set.

CurrentMonth.Item(0).Item(0).Lag(1) will give you the previous month with data.

I know that there is an issue with Aggregate() if you use a time function(YTD(),ParallellPeriod()) in it. It will return null. So far I have not found out if it is a bug or a feature.

Can Paul G , Chris Webb, Mosha or Deepak comment?

Regards

Thomas Ivarsson

ThomasIvarsson at 2007-9-3 > top of Msdn Tech,SQL Server,SQL Server Analysis Services...
# 6

I was using a shell dimension for my time calculations. Moving my calculation into the actual time dimension has fixed the problem. To be honest I'm not 100% sure why. Thanks for the tip on referencing existing sets and your help in achieving this solution.

Mark

mamo at 2007-9-3 > top of Msdn Tech,SQL Server,SQL Server Analysis Services...

SQL Server

Site Classified