Comparing elements between dimensions

Post Reply
Daniel
Posts: 6
Joined: Mon Jul 11, 2016 11:23 pm
OLAP Product: cognos tm1
Version: 10.2.
Excel Version: 2013

Comparing elements between dimensions

Post by Daniel »

Hello everyone! Guys, I am quite a newby in TM1, so probably I have a quite obvious question =)
Does anyone know how to use arrays in TM1 ? The thing I want to do is the next:

IF one element from the dimension is equal to at least one in another dimension - then
cellputN - 0, insert zero
else cellputn- 1. insert 1
endIF.

Thats it :) Does anybody know how to do that ?

I would be very grateful for any help, thanks in advance !
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: Comparing elements between dimensions

Post by tomok »

Don't know what this has to do with arrays but in any case there is no such thing in TM1. Sounds like you want to compare all the elements in one dimension against one or more elements in other dimension(s). The only way to do that in a TI process is going to do a WHILE loop, stepping through the source dimension, one by one, and then stepping through all the target dimensions and comparing source against target. Something like:

Code: Select all

i = 1;
vSourceSize = DIMSIZ('SourceDim');
WHILE (i <= vSourceSize);
  sSourceElement = DIMNM('SourceDim', i);
  j = 1;
  vTargetSize = DIMSIZ('TargetDim');
  WHILE ( j <= vTargetSize);
    sTargetElement = DIMNM('TargetDim', j);
    IF(sSourceElement @= sTargetElement);
      Do Your Thing
    ENDIF;
    j = j + 1;
  END;
  i = i + 1;
END;
Tom O'Kelley - Manager Finance Systems
American Tower
http://www.onlinecourtreservations.com/
lotsaram
MVP
Posts: 3704
Joined: Fri Mar 13, 2009 11:14 am
OLAP Product: TableManager1
Version: PA 2.0.x
Excel Version: Office 365
Location: Switzerland

Re: Comparing elements between dimensions

Post by lotsaram »

Daniel wrote:IF one element from the dimension is equal to at least one in another dimension - then
cellputN - 0, insert zero
else cellputn- 1. insert 1
endIF.
May I ask WHY? How does it matter if an element has the same ID as an element in another dimension?

Tom's code will answer your question but why do you ask it in the first place. If you want to consider possible alias matches in both dimensions as well as principal name then you would need to add 2 additional while loops.
Please place all requests for help in a public thread. I will not answer PMs requesting assistance.
Post Reply