Have you ever looked for a TM1 function that checks if an attribute exists, something like say “AttributeExists” or “AttrExists”. Well there isn’t one. But, don’t dispair, here is a quick method you can use to do exactly that in a Turbo Integrator process.
I am writing a TI to build and then subsequently update a dimension. Right up front I am defining a bunch of variables, like the dimension name. Then I am using the DimensionExists function to check of the dimension actually exists, and if not, creating it using DimensionCreate. Finally I want to check if there is an attribute on that dimension and if not, create it.
Attribute Exists Code Example
Then I have a little bit of code that checks to see if an attribute exists and if not, then it is added. The code is:
## Check if Attributes Exist and if not, add them vDimName = 'Product' vAttribute1 = 'Name'; IF ( DIMIX ('}Element_Attributes_' | vDimName, vAttribute1 ) = 0); ATTRINSERT ( pDimName,'', vAttribute1 ,'s'); ENDIF;
What this is doing is defining the dimension and attribute. Then it uses a DIMIX to check if the attribute exists in the Control Object for the Element Attributes for the Dimension. Then if it the answer is no (a Zero), then it inserts the attribute into the dimension using ATTRINSERT. Note the type of attrubute is defined as String, Alias or Numeric (S, A or N).
So this is a really easy way of checking if an attribute exists and then adding it to a dimension without being able to use the non-existent AttributeExists function!