Calculate from day before

Post Reply
Willi
Regular Participant
Posts: 151
Joined: Mon Oct 07, 2013 11:51 am
OLAP Product: TM1
Version: 9.5.2
Excel Version: 2010

Calculate from day before

Post by Willi »

Hello,

I have a cube with 4 Dimensions:

- Year
- MonthDay
- People
- Measure

The structure of Year is:

Code: Select all

Alle Jahre
2011
2012
2013
2014
2015
.
.
.
The structure of MonthDay is:

Code: Select all

Alle Monate
  01
    0101
    0102
    0103
    0104
    0105
    0106
.
.
. (until 1231)
People is like Year just with names and Mesures are some Measure-Numbers.

Now I want to calculate one Measure of one day from another Measuere the day before. I tried the following rule:

Code: Select all

# To leave the first day untouched
['2011','0101','Bestand'] = N: STET;
# Calculation "Bestand from Today = Kasse from Yesterday"
['Bestand'] = N: DB('Cube',
                    SUBST(DATE(DAYNO(!Year|'-'|SUBST(!MonthDay,1,2)|'-'|SUBST(!MonthDay,3,2))-1,1),1,4),
                    SUBST(DATE(DAYNO(!Year|'-'|SUBST(!MonthDay,1,2)|'-'|SUBST(!MonthDay,3,2))-1,1),6,2)|SUBST(DATE(DAYNO(!Year|'-'|SUBST(!MonthDay,1,2)|'-'|SUBST(!MonthDay,3,2))-1,1),9,2),
                    !People,
                    'Kasse');
I guess the calculation of "Yesterday" could be a bit easier but it workd. Thst's not my Problem.

If I start the Server and start Cubeviewer with this year I see "#N/A" and the "Circular reference" Error Message for the Measure "Betrag". But when I Change the year to 2011 it's working. and when I step in cubeviewer from year to year until today I see the correct value for today. Also when I Change a value in the back years I get the Error for today until I step through the cubeviewer year by year

Is my Approach possible and how can I get the correct values at once?

Thx and regards,
Willi

P.S: It's TM1 Version 10.2.2 FP1
tomok
MVP
Posts: 2836
Joined: Tue Feb 16, 2010 2:39 pm
OLAP Product: TM1, Palo
Version: Beginning of time thru 10.2
Excel Version: 2003-2007-2010-2013
Location: Atlanta, GA
Contact:

Re: Calculate from day before

Post by tomok »

If you are getting a circular error message for "Betrag" then I can assume it is a rule calculated measure as well. Why did you not include the code for that calculation? Don't see how anyone can help you without it. As for your method of figuring out the previous day, while it may work I would avoid it. String calcs are some of the slowest. You'll always know what the previous day value will be for a specific day AND it will never change. Better to create an attribute called "PreviousDay" and populate it with the element reference for that day. The you can replace your SUBST mess with ATTRS('MonthDay', !MonthDay, 'PreviousDay').
Tom O'Kelley - Manager Finance Systems
American Tower
http://www.onlinecourtreservations.com/
Willi
Regular Participant
Posts: 151
Joined: Mon Oct 07, 2013 11:51 am
OLAP Product: TM1
Version: 9.5.2
Excel Version: 2010

Re: Calculate from day before

Post by Willi »

Thx for the reply. I'm just in the process to Change the SUBST-mess with an Attribute.

But the other Problem: I totally agree that I should have a look at the calculations if there won't the correct calculation after I stepped year by year through the cubeviewer!?
tomok
MVP
Posts: 2836
Joined: Tue Feb 16, 2010 2:39 pm
OLAP Product: TM1, Palo
Version: Beginning of time thru 10.2
Excel Version: 2003-2007-2010-2013
Location: Atlanta, GA
Contact:

Re: Calculate from day before

Post by tomok »

Willi wrote:But the other Problem: I totally agree that I should have a look at the calculations if there won't the correct calculation after I stepped year by year through the cubeviewer!?
I have no clue what you are trying to say/ask with that statement.
Tom O'Kelley - Manager Finance Systems
American Tower
http://www.onlinecourtreservations.com/
Willi
Regular Participant
Posts: 151
Joined: Mon Oct 07, 2013 11:51 am
OLAP Product: TM1
Version: 9.5.2
Excel Version: 2010

Re: Calculate from day before

Post by Willi »

Sorry. I attach some Little Screenshots. I start the Server and the Cubeviewer and see this:
Rule1.JPG
Rule1.JPG (22.31 KiB) Viewed 5896 times
Than I only Change the upper left selection to the first year and get the result in Picture Rule2.JPG
Rule2.JPG
Rule2.JPG (22.67 KiB) Viewed 5896 times
Than again I Change the year to the second year: (Attachement deleted, probably only 3 allowed)

and so on until I'm back to the first selection:
Rule4.JPG
Rule4.JPG (25.99 KiB) Viewed 5896 times
That's what i don't understand and what makes me think that it's not a circular refence-issue.
kangkc
Community Contributor
Posts: 206
Joined: Fri Oct 17, 2008 2:40 am
OLAP Product: TM1, PA , TMVGate
Version: 2.x
Excel Version: 36x
Location: Singapore
Contact:

Re: Calculate from day before

Post by kangkc »

Check the server log, I suspect you may be hitting stack overflow issue with rule. This is not a TM1 bug but rather some application re-design is required.
The error may appear as circular reference when you trace the rule.

Stack overflow is common if there is a reference back in rule which exhausted the stack buffer. Till date I have not been able to determine the actual stack buffer allocated in TM1 but I think it's different for respective release of TM1.
Willi
Regular Participant
Posts: 151
Joined: Mon Oct 07, 2013 11:51 am
OLAP Product: TM1
Version: 9.5.2
Excel Version: 2010

Re: Calculate from day before

Post by Willi »

Thx, that was really the Problem.So for now I put this in a TI and rethink later if I can Change it to a rule in another way.
User avatar
qml
MVP
Posts: 1098
Joined: Mon Feb 01, 2010 1:01 pm
OLAP Product: TM1 / Planning Analytics
Version: 2.0.9 and all previous
Excel Version: 2007 - 2016
Location: London, UK, Europe

Re: Calculate from day before

Post by qml »

I think the size of the rule stack and therefore the achievable level of recursion is still in the vicinity of 255 (you can definitely do a search of the forum, it has been discussed).
If you break it down in such a way that the first day of each quarter or month is STETed out then you only need to use TI to populate that first day of each period and the rest should be ok to do using rules. Of course a lot depends on whether you are still getting acceptable performance with that level of recursion.
Kamil Arendt
tomok
MVP
Posts: 2836
Joined: Tue Feb 16, 2010 2:39 pm
OLAP Product: TM1, Palo
Version: Beginning of time thru 10.2
Excel Version: 2003-2007-2010-2013
Location: Atlanta, GA
Contact:

Re: Calculate from day before

Post by tomok »

I use this "previous period" concept all the time in TM1 and never have any issues with stack overflows. You must be daisy-chaining these "yesterday" values past the allowable stack limit. If "yesterday" is always based on "today" from a day ago and "today" is not dependent on the "yesterday" value then you should never have a stack overflow. If you are doing some daisy-chaining then you should rethink your logic.
Tom O'Kelley - Manager Finance Systems
American Tower
http://www.onlinecourtreservations.com/
Post Reply