Rule - referencing the prior year

Post Reply
chewza
Regular Participant
Posts: 156
Joined: Tue Aug 17, 2010 11:51 am
OLAP Product: TM1
Version: 9.5
Excel Version: 7

Rule - referencing the prior year

Post by chewza »

Hi there

In my rule, I am trying to access the previous year.
Was hoping that something like '.......!Year-1....' would work, but no luck!

I know that I could use attributes to achieve this, whereby I can specify a prior year attribute for each dimension element, and reference this, but is there no way to achieve this using the method I am attempting above..??

Regards
Chris
User avatar
Michel Zijlema
Site Admin
Posts: 713
Joined: Wed May 14, 2008 5:22 am
OLAP Product: TM1, PALO
Version: both 2.5 and higher
Excel Version: 2003-2007-2010
Location: Netherlands
Contact:

Re: Rule - referencing the prior year

Post by Michel Zijlema »

Hi Chris,

The !Year parameter refers to an elementname in a dimension, which is a string value.
If you want to make the rule work this way you need to convert to number, subtract 1 and convert back to string. The correct notation would be: Str(Value(!Year)-1, 4, 0).

Michel
User avatar
Michel Zijlema
Site Admin
Posts: 713
Joined: Wed May 14, 2008 5:22 am
OLAP Product: TM1, PALO
Version: both 2.5 and higher
Excel Version: 2003-2007-2010
Location: Netherlands
Contact:

Re: Rule - referencing the prior year

Post by Michel Zijlema »

Michel Zijlema wrote:The correct notation would be: Str(Value(!Year)-1, 4, 0).
Oops, this is not PALO... :)
The correct notation would be Str(Numbr(!Year)-1, 4, 0).

Michel
lotsaram
MVP
Posts: 3706
Joined: Fri Mar 13, 2009 11:14 am
OLAP Product: TableManager1
Version: PA 2.0.x
Excel Version: Office 365
Location: Switzerland

Re: Rule - referencing the prior year

Post by lotsaram »

Michel Zijlema wrote:The correct notation would be Str(Numbr(!Year)-1, 4, 0)
This assumes that the year dimension is in a yyyy format. This is not always going to be the case, where financial years and calendar years are not the same the format for the year dimension can often be something like "10-11" or "FY11" in which case this is not going to work. In that case you need something else. For reasons known only to the original developers TM1 has a DNEXT element information function but no equivalent "DPREV" function, you would therefore need to combine DIMIX and DIMNM, for example:
DIMNM('Year', DIMIX('Year', !Year) - 1);
However in my opinion it is never a good idea to make rules dependent on dimension structure or indexing as this could easily change and have many unwelcome consequences, it is always better to base these kinds of time calculations on either attributes or lookup cubes, for example:
AttrS('Year', !Year, 'Prev Year');
chewza
Regular Participant
Posts: 156
Joined: Tue Aug 17, 2010 11:51 am
OLAP Product: TM1
Version: 9.5
Excel Version: 7

Re: Rule - referencing the prior year

Post by chewza »

Brilliant - thanks guys! Very helpful
Post Reply