Testing for current month and prior month

Post Reply
User avatar
Steve Rowe
Site Admin
Posts: 2464
Joined: Wed May 14, 2008 4:25 pm
OLAP Product: TM1
Version: TM1 v6,v7,v8,v9,v10,v11+PAW
Excel Version: Nearly all of them

Testing for current month and prior month

Post by Steve Rowe »

I've not been able to figure out a way of doing this so thought I'd see if someone has a smart way of doing this.

The problem
In a rule set I need to test if the period in the rule space is equal to the current or the prior month as set in another cube. This is trivial to do with two logic tests.
i.e.

Code: Select all

[]=N: If ( Numbr (!Year | !Month ) = DB ( ref to current month setting) % Numbr (!Year | !Month ) = DB ( ref to prior month setting), etc
In an effort to make my rules more efficent though I'd like to achieve the same logic using a single logic test so I don't have to repeat the lookup to the current month cube. The DB to the where the current month is held contains two other DBs in my actual system which is why I think its worth making the effort and I need to use the above logic to condionalise all my feeders.

Code: Select all

[]=N: If ( MOD ( DB ( ref to current month setting) , Numbr (!Year | !Month ))<=1 , etc
The above comes close but doesn't work when the current month is 201101 for example.
Technical Director
www.infocat.co.uk
Duncan P
MVP
Posts: 600
Joined: Wed Aug 17, 2011 1:19 pm
OLAP Product: TM1
Version: 9.5.2 10.1 10.2
Excel Version: 2003 2007
Location: York, UK

Re: Testing for current month and prior month

Post by Duncan P »

How about ...

Change the current month source to contain <EDIT>the string</EDIT>

Code: Select all

previous_month | ',' | current_month
then change the test to be

Code: Select all

0 < SCAN( !Year | !Month, DB( ref to current and previous month source ) )
Would that work?
User avatar
Steve Rowe
Site Admin
Posts: 2464
Joined: Wed May 14, 2008 4:25 pm
OLAP Product: TM1
Version: TM1 v6,v7,v8,v9,v10,v11+PAW
Excel Version: Nearly all of them

Re: Testing for current month and prior month

Post by Steve Rowe »

Yes, thanks Duncan,
I actually thought of another way of doing this

If I calculate the things that I am testing like this

Code: Select all

Numbr (!Year) *12 + Numbr( !Month)
then the mod approach works since you gat a continuous sequence of numbers.
Cheers,
Technical Director
www.infocat.co.uk
Post Reply