Combining LastPeriods and Cube reference in MDX

Post Reply
fleaster
Regular Participant
Posts: 167
Joined: Wed Mar 30, 2011 11:57 pm
OLAP Product: TM1
Version: 10.2.2
Excel Version: XL2010

Combining LastPeriods and Cube reference in MDX

Post by fleaster »

Hi all,
we currently have 2 x MDX dynamic subsets that (a) extract the current month period and (b) creates a subset of the last 12 months based on what the current month is:

Code: Select all

(a)
{TM1FILTERBYPATTERN( {TM1SUBSETALL( [Period] )}, 
[z_ctrl_measures].([z_ctrl_measures].[Current Month],[z_String].[String 1])
)}

(b)
LastPeriods(12, [Period].[Aug 2016])
Note: (b) is refreshed on a regular basis via another process

...the question is, is it possible to combine these 2 MDX subsets into a new one that returns the last 12 months based on the current month cube reference? Am struggling with the syntax for this e.g.

Code: Select all

???
LastPeriods(12, [Period].([z_ctrl_measures].([z_ctrl_measures].[Current Month],[z_String].[String 1])) )
...so if anyone has any tips on correcting it, it would be much appreciated :)

thanks!

Matt
declanr
MVP
Posts: 1828
Joined: Mon Dec 05, 2011 11:51 am
OLAP Product: Cognos TM1
Version: PA2.0 and most of the old ones
Excel Version: All of em
Location: Manchester, United Kingdom
Contact:

Re: Combining LastPeriods and Cube reference in MDX

Post by declanr »

I think you just need to use StrToMember around the period before you put it into the second query.

Code: Select all

StrToMember("[Period].[" + [z_ctrl_measures].([z_ctrl_measures].[Current Month],[z_String].[String 1]) +"]")
Declan Rodger
fleaster
Regular Participant
Posts: 167
Joined: Wed Mar 30, 2011 11:57 pm
OLAP Product: TM1
Version: 10.2.2
Excel Version: XL2010

Re: Combining LastPeriods and Cube reference in MDX

Post by fleaster »

Thanks muchly! Have plugged it in and can confirm it now works :)

Code: Select all

LastPeriods(12, StrToMember("[Period].[" + [z_ctrl_measures].([z_ctrl_measures].[Current Month],[z_String].[String 1]) +"]") )
Post Reply