Page 1 of 1
Rule - referencing the prior year
Posted: Mon Aug 23, 2010 7:36 am
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
Re: Rule - referencing the prior year
Posted: Mon Aug 23, 2010 7:55 am
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
Re: Rule - referencing the prior year
Posted: Mon Aug 23, 2010 8:00 am
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
Re: Rule - referencing the prior year
Posted: Mon Aug 23, 2010 12:47 pm
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');
Re: Rule - referencing the prior year
Posted: Tue Aug 24, 2010 7:30 am
by chewza
Brilliant - thanks guys! Very helpful