DB function inside the same cube and other questions

Post Reply
simontanguay
Posts: 6
Joined: Thu Jan 22, 2015 3:25 pm
OLAP Product: none
Version: 10.1.1
Excel Version: 2010

DB function inside the same cube and other questions

Post by simontanguay »

Hi,

I'm pretty new to using the feeders and I'm editing codes left by another developer. I noticed that the developer frequently used the DB function when feeding data inside the same cube. For instance:

Code: Select all

['adj','simulation 1','VN $']=n:if (db('Ventes',!produits,!routes,!rabais,!client,'bkd','simulation 1',!banner_div,!year_week,'VN $ Target')<>0,
db('Ventes',!produits,!routes,!rabais,!client,'bkd','simulation 1',!banner_div,!year_week,'VN $ Target') -
db('Ventes',!produits,!routes,!rabais,!client,'bkd','simulation 1',!banner_div,!year_week,'VN $'),0);
FEEDERS;
['bkd','simulation 1','VN $ Target']=>db('Ventes',!produits,!routes,!rabais,!client,'adj','simulation 1',!banner_div,!year_week,'VN $');
Those are sample of code inside the rules of cube "Ventes", so the use of the DB function seems unnecessary. My understanding of the DB function is that it's necessary only when accessing data from another cube. Is there another good reason to use it inside the same cube or this is a bad practice?

While I'm at it, I will ask another newbie question.

I added the following rules to the cube:

Code: Select all

['Bkd', 'Réel', 'BB$ Calc']= N: IF(['Bkd', 'Réel', 'BB$ Deb'] = 0, ['Bkd', 'Réel', 'BB$'], ['Bkd', 'Réel', 'BB$ Deb']) ;
FEEDERS;
['Bkd', 'Réel', 'BB$']=>['Bkd', 'Réel', 'BB$ Calc'];
['Bkd', 'Réel', 'BB$ Deb']=>['Bkd', 'Réel', 'BB$ Calc'];
My test have shown that both feeders were necessary, the same way it would be if I was doing an addition between 'BB$' and 'BB$ Deb'. Still, I have some doubt about if this is an optimal practice or if there is a better way. In that case, I tested for equality ((['Bkd', 'Réel', 'BB$ Deb'] = 0) since when I tested for "greater than" with the True/False reversed, it didn't work property. My original rule was (with both feeders above):

Code: Select all

['Bkd', 'Réel', 'BB$ Calc']= N: IF(['Bkd', 'Réel', 'BB$ Deb'] > 0, ['Bkd', 'Réel', 'BB$ Deb'], ['Bkd', 'Réel', 'BB$']) ;
Last question: Is there an advantage to make an assignment on leaves only ( = N: ) as the result are the same as if I had used a simple assignment ( = ) since TM1 calculate the consolidation anyway. Is there a performance or reliability advantage to use one over the other in such simple case?

Thanks for you support.
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: DB function inside the same cube and other questions

Post by Duncan P »

The DB function is useful, indeed necessary, within the same cube in the following scenarios
  • Accessing string data - this can not be done with the ['item'...] syntax
  • Accessing data where the location of the source cell depends on other data - the ['item'...] syntax only allows constant strings, whereas DB('cube', DB('source_locations',... is perfectly possible
  • Writing a feeder where the target of the feeder depends on other data - this is needed for the case above
In answer to your last question about N: in your case it is possible that "BB$ Deb" could have both positive and negative values at leaf level. In both cases these would be used in "BB$ Calc". If at an aggregate level the sum of these positive and negative values was 0, then using the N: rule the 0 would be left (as it is C: level and not affected) but if you use plain = (both N: and C:) it would be replaced by "BB$". You chose the behaviour you want.
simontanguay
Posts: 6
Joined: Thu Jan 22, 2015 3:25 pm
OLAP Product: none
Version: 10.1.1
Excel Version: 2010

Re: DB function inside the same cube and other questions

Post by simontanguay »

Thanks, that answer it perfectly. In the case of the last question, BB$ and BB$ Deb are expected to always have the same sign, but I will consider what best to handle anomaly gracefully. I also realized that this is why I got inconsistent results when using a ">" in the IF clause, there are indeed a posibility of negative values that I didn't expect.
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: DB function inside the same cube and other questions

Post by tomok »

simontanguay wrote:Thanks, that answer it perfectly. In the case of the last question, BB$ and BB$ Deb are expected to always have the same sign, but I will consider what best to handle anomaly gracefully. I also realized that this is why I got inconsistent results when using a ">" in the IF clause, there are indeed a posibility of negative values that I didn't expect.
A perfect example of why they have the ABS function.
Tom O'Kelley - Manager Finance Systems
American Tower
http://www.onlinecourtreservations.com/
Post Reply