Array Variables

Ideas and tips for enhancing your TM1 application
Post Reply
Christopher Kernahan
Community Contributor
Posts: 147
Joined: Mon Nov 29, 2010 6:30 pm
OLAP Product: Cognos TM1
Version: 10.1
Excel Version: Office 2010

Array Variables

Post by Christopher Kernahan »

I'm not sure if this has been covered before; I did search the Forum.

I used the below code to construct an "Array" in TM1. Each run of the While loop takes the variable and adds another value onto it, delimiting it with a ';' to identify the join. The second While loop deconstructs the array.

It was useful for my purposes but I haven't tested the performance or other (ie character?) limitations of this method.

Code: Select all


iCount = 0;
iLimit = 10;
vArray = '';

WHILE( iCount < iLimit);

             vValue = Some Calculation or String Manipulation;
         
             vArray = vArray | vValue | ';'  ;

             iCount = iCount + 1;

END;

iCount = 0;
iLimit = 10;

WHILE( iCount < iLimit);

              vValue = SUBST( vArray, 1, SCAN( ';', vArray) - 1);

              vArray = DELET( vArray, 1, SCAN( ';', vArray));

              iCount = iCount + 1;

END;
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: Array Variables

Post by Duncan P »

Have a look here

http://www.tm1forum.com/viewtopic.php?p=27954

The answer is that if you are doing this for small numbers of items (e.g. TI variables) it's fine. If you get into the thousands (e.g. items of a dimension) it is a very bad idea.
Post Reply