This article is the second part of a 3-part series exploring attribute manipulations with Turbo Integrator (TI) processes. In Part 1 of the series, which can be found here, we saw how to check if an attribute exists and insert it and then how to check its type.

We will now continue with a more advanced example on what to do once we find a certain type of attribute.

Creating a subset with only Alias attributes

There are situations when we may need to loop through a dimension in order to perform some tasks for each element. (In this example, we will use the dimension plan_business_unit in the Planning Analytics Planning Sample model).

An attribute dimension is a “control” dimension with a combination of string, numeric and alias type elements. We often have the task to find specific element types and create a subset or export a file.

In the example below, the code has the steps necessary to perform the task of looping through a control dimension, then creating a subset and exporting a file:

  1. The code first specifies a set of variables with the dimension name, the name of the subset to create and the export location where you want the elements to be exported.
  2. We use the SubsetExists function to check if the subset already exists, if yes, then delete it (because will create it again with new elements), using the SubsetDestroy function.
  3. We use the WHILE function to loop through the dimension, then performing a check of the each element’s type using the DTYPE function, then adding elements that meet the criteria to our subset and also to an export file. We use functions SubsetElementInsert and ASCIIOUTPUT, respectively.

Note: as noted in Part 1 of this article’s series, ElemType=AA refers to alias elements in a control dimension.

The result of the above code is a subset called Dim Alias List and an *.txt file

Setting an attribute format

A very common use of the WHILE function for looping through dimensions is when we have large dimensions. For instance, we may want to set a numeric format for all Numeric (N) elements in a dimension. If the dimension is very large, this can take a very long time to do manually. But we can be more efficient by doing it via TI as shown in the code below with the following steps:

1. We first set a variable with the dimension name

2. We then use the DIMIX function to check if the attribute called Format exists

a. Note: If this is a new dimension, the Format attribute will not be created automatically by the system, so we need to check if it exists.

3. If the Format attribute doesn’t exist then add it, otherwise we will get an error on the next step.

4. USE the WHILE function to loop through the dimension elements and only add formatting to Numeric elements.

We will continue exploring attribute manipulations in a Part 3 article found HERE.