Page 1 of 1

Removing Redundant Children from alternative hirearchies

Posted: Thu Apr 26, 2012 2:14 am
by jameswebber
Removing Redundant Children from alternative hierarchies

Hi just after some tips for the best way to clean up a dimension with multiple hierarchies.
I’m using TI to create a number of additional hierarchies based on attributes:

Code: Select all

IF (PContract@='');
   PContract= 'Unspec Contract';
ENDIF;

IF (DIMIX(DimName,PContract)=0);
   DimensionElementInsert(DimName, '', PContract,  'C');
   DimensionElementComponentAdd(DimName, 'Total Project ID by Contract', PContract, 1);
ENDIF;

DimensionElementComponentAdd(DimName, PContract, ElName, 1);
These attributes are getting populated via ODBC but I hadn’t anticipated that the attribute can change. Creating double ups in my alternative hierarchy E.g Project 1 in both places below:
Total Project ID by Contract
AttributeA
  • Project 1
    Project 3
AttributeB
  • Project 1
    Project 2
I looked at Ben Hills example and modified it http://blog.tm1tutorials.com/tag/dimens ... entdelete/
This is because I want to unwind my hierarchy but not the other hierarchies in the system
I created TI that looks up the parent sees if it’s one I’m interested in then finds the children and removes them from the dimension see below:

Code: Select all

vIndex = 1;
vElParN = ELPARN(DimName, Project_ID);


While (vIndex<=vElParN);
   vElPar  = ELPAR (DimName, Project_id, vindex);


## This code is to unwind the project hierarchies but only for the project hierarchies we are creating in Dim Project ID 7. Consolidation by Class
## This is because the TI there adds into the hierarchy but does not delete redundant ones
## Added by James Webber IRL 120427 see TMI-241
## Based on Ben Hills Example http://blog.tm1tutorials.com/tag/dimensionelementcomponentdelete/

# Frist lets check to see if the Parent of the project is total contract
If (vElpar @= 'Total Project ID by Contract');
   # Now how many children are there underneath?
      ChildCount =  ELCOMPN(DimName, Project_Id);
                  # find the name of each of the children
                 WHILE(ChildCount > 0);
                 sChildElm = ELCOMP(DimName, Project_Id,ChildCount);                       
                      #Now check the child name is an ancestor (child) of the project_ID, i.e the node in this case
                       #IF (ELISANC(DimName, Project_Id, sChildElm) = 1);
                       # If so remove it from the hierarchy
                       DimensionElementComponentDelete(DimName, Project_Id, sChildElm);
                       #ENDIF;

                ChildCount = ChildCount - 1;
               end;
ENDIF;

vElParN = vElParN-1;

END;

This works but does anyone know of a more elegant way to find out all elements under an alternative hierarchy and remove these entries from the dimension?
I.e. is there a more elegant way of doing this?

Re: Removing Redundant Children from alternative hirearchies

Posted: Thu Apr 26, 2012 5:01 am
by jameswebber
Just wondering if my double entry is really caused but the users not reloading the view rather than simply choosing the refresh button
tm1-test -_2012-04-26_Refressh.png
tm1-test -_2012-04-26_Refressh.png (29.87 KiB) Viewed 3946 times
I have noticed in testing that I get double entries in the hierarchy if I don't choose reload. Even commented out my TI process and it seems to be okay.

Re: Removing Redundant Children from alternative hirearchies

Posted: Thu Apr 26, 2012 6:57 am
by lotsaram
Bedrock.Dim.Unwind.TargetConsol

Re: Removing Redundant Children from alternative hirearchies

Posted: Thu Apr 26, 2012 10:23 pm
by jameswebber
Thanks Lotsaram,
Bedrock.Dim.Hierarchy.Unwind.Consolidation seems to work fine just needed to make sure pRecursive is set to 1 (Delete all the relationsips from all the elements under the nominated consolidation)
Otherwise there is a lot of orphans floating around.