Page 1 of 1
Comparing elements between dimensions
Posted: Wed Jul 13, 2016 9:02 pm
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 !
Re: Comparing elements between dimensions
Posted: Wed Jul 13, 2016 9:30 pm
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;
Re: Comparing elements between dimensions
Posted: Thu Jul 14, 2016 5:18 am
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.