WHILE TM1 Function: Syntax and Use

Sometimes in a TI process we need to run loops. This is often done to aggregate data prior to loading or exporting. The TI process we use for this is called WHILE and it will force a set of commands to repeat until the condition set becomes invalid.

Syntax of While

WHILE ( logical expression);
TI statement1;
TI statement2;
TI statement n;


Here we want to export both monthly and year to date values for the current intersection.

nLoopCount = nLoopCount = ATTRN ('Month', vMonth , 'Month No');

nYTDValue = 0;

sMonthValue = numbertostring ( Value );

WHILE ( nLoopCount > 0);

nYTDValue = nYTDValue + CellGetN(cSourceCube, vDim1, vDim2, vDim3, vDim4, vMeasure);

nLoopCount = nLoopCount - 1;


sYTDValue = NumberToString(nYTDValue);

ASCIIOUTPUT ( vPath|vFile, Dim1, vDim2, vDim3, vDim4, vMeasure, sMonthValue,sYTDValue );

This code sets up the variable to asses inside the loop, converts the monthly value to string, starts the loop (assessing of the count is greater than zero), then accumulates a YTD value and sets the looping variable to 1 less than it’s prior value (as we want to count it down to zero). Finally we convert the YTD to a string and then export it using AsciiOutput.

This function is valid only in TurboIntegrator processes.


If you like this post, please spread the love…

About John

Managing Director of Infocube. We are a management accounting consultancy that specialises in Business Analytics.
This entry was posted in TI Coding, TI Functions. Bookmark the permalink.