Exploring TM1 - a Chartertech Company
Search
Close this search box.

WHILE Function: How to Use, Syntax, and Examples

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


Syntax of While Function

While Function Syntax

Example

Here, we want to export both monthly and year-to-date values for the current intersection using the WHILE function:

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;

END;

sYTDValue = NumberToString(nYTDValue);

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


This code sets up the variable to assess 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.

  • This field is for validation purposes and should be left unchanged.

Post Sections

Related Posts

John Vaughan

John Vaughan

John is a CPA, MBA and has been a Performance Management consultant for over 25 years. He is the founder of ExploringTM1 and highly regarded for his experience combining financial management with corporate planning, reporting and analysis. He lives in Sydney with his wife, two of his three children, their cat, Freckles, a bunch of chooks and some fish. John is a sports nut, who played rugby until he was 40, started playing football at 54 and loves being outdoors.

Leave a Reply

Your email address will not be published. Required fields are marked *

Log In