DimensionElementComponentAdd TM1 Function: How to Use, Examples and Syntax
DimensionElementComponentAdd adds an existing element in a TM1 dimension into a hierarchy as a child of another element. In other words, it is used to create rollups.
Syntax of DimensionElementComponentAdd
The syntax is:
DimensionElementComponentAdd ( DimName, ConsolidatedElName , ElName , ElWeight);
- DimName is the dimension you want to work with.
- ConsolidatedElName is the element to which you want to add a child.
- ElName is the name of the child element.
- ElWeight is the weight of the child element. This is usually either 1 to add positive values, or -1 to subtract values from the parent. If you would like to read a full explanation of how to use weights, please see this post.
Usage and Example
DimensionElementComponentAdd is often used in combination with the DimensionElementInsert statement. Therefore, after you have added a new element, you then need to add it into a hierarchy.
DimensionElementComponentAdd ('GL Account', vParent_Account, vSub_Account, 1);
This will add the current contents of the variable vSub_Account to vParent_Account in the GL Account dimension with a weight of 1. In other words, positive values will add to the parent.
Often this function is used in conjunction with DIMIX to test if an element exists. Then, if it doesn’t using DimensionElementInsert to insert it. Then finally using DimensionElementComponentAdd to add it into a hierarchy. The code to do this would look like this:
## Add all elements from source sAccountID = vAccountID ; IF(DIMIX(DimName, sAccountID )=0); DimensionElementInsert(DimName, '', sAccountID ,'N'); ENDIF; ## Add Account Types as elements for Trial Balance Rollup sAccountType = vAccountType; IF(DIMIX(DimName, sAccountType )=0); DimensionElementInsert(DimName, '', sAccountType ,'C'); ENDIF; # Roll elements up sParentID = ConsName; IF ( sParentID @<> ''); DimensionElementComponentAdd(DimName, sAccountType, sAccountID , 1); ENDIF;
It might also be used with a DIMIX to test if a potential parent exists before having the element in question being added to that parent.
Notes and Tip Regarding a Potential Error
- The opposite of this function is DimensionElementComponentDelete.
- This function can only be used in Turbo Integrator processes.
- It also can only be used on Prolog or Metadata tabs (not the Data tab, it won’t do anything there!).
- If you are creating elements and rolling them up in the process, the parent elements need to be higher in the source than the child elements. If the child elements came first, say with an ID of “Child” and a ParentID of “Parent” and then the parent ID was added afterwards, ParentID would not exist in the dimension when you were trying to apply DimensionElementComponentAdd. This would give an error, saying that ParentID could not be found. Then if you ran it again, the error would magically disappear. Make sure your parents are added first!