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

Leave a Reply

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

Log In