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

AttrInsert TM1 Function: Use and Sytax

Sometimes we want to create a new attribute in TM1 dynamically during the execution of a TI process. This function allows us to do that and create either a string, a numeric or an alias attribute.

Syntax of AttrInsert

The syntax is:

AttrInsert ( DimName, PrevAttr, AttrName, Type );

where:

  • DimName – is the name of the dimension that you want to create an attribute on
  • PrevAttr – is the name of the attribute immediately before the new attribute that you want to insert (so you get the attributes in the right order!).
  • AttrName – is the name of the new attribute you are creating
  • Type – is the type of attribute you are creating, either ‘N’, for numeric, ‘S’ for string or ‘A’ for an alias.

Example of AttrInsert

DimName = 'Employees';

AttrInsert ( DimName,  'Name',  'Status' , 'S' );

Here we have defined a variable called DimName with ‘Employees’ in the Prolog. Then lower down in the Prolog we have used the variable to tell the AttrInsert to create a new String attribute called ‘Status’ in the Employees dimensions after the existing ‘Name’ attribute.

Real World Usage

Interestingly we had immediately prior to this function in our TI used AttrDelete to delete the attribute. This effectively clears out all the values in the attribute before then on the Metadata or Data tab we re-populate it with current information.

Also, we sometimes want to check if an Attrubute exists prior to doing an insert. Please see this post about how to effecively do an AttributeExists function (even though it does not exist in TM1!).

Note that if you are going to create an attribute and then populate it in a single TI, you must create the attribute on the Prolog tab and then populate it on either the Metadata or Data tab.

This function can only be used in Turbo Integrator 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