Page 1 of 1

TI process to delete all C elements in a particular hierachy

Posted: Wed Oct 13, 2010 4:23 am
by jydell
Hi

I have an alternative dimension hierachy that is to be destroyed and rebuilt every night (rebuilt based on CSV file). Only C levels to be rebuilt (N elements not to be touched to preserve data). I can figure out how to build this however I can not find an easy way to destroy a particular hierachy and all its C element children. (given I dont know the children names)

"DIMENSIONELEMENTDELETE" works but as I do not know the names of the children I cannot hardcode it. I have considered dynamic MDX subsets but figure this will not work as the subset would change each time I delete a C element child.

Can anyone help with how I can destroy all consolidaion levels under a parent in a dimension.

Re: TI process to delete all C elements in a particular hier

Posted: Wed Oct 13, 2010 4:40 am
by jrizk
The following. If you want to be more specific about which hierarchy you want to unwind/rebuild (say if you had several hierarchies) you will need to put a flag as an attribute against the hierarchy/consolidation elements you want unwind and add a test for this flag in the following script..

DimName = 'yourDimName';
DimCount = DimSiz ( DimName );

i = 1;
While ( i <= DimCount ) ;
DimCount = DimSiz (DimName);
El = DimNm ( DimName , i);
ChildCount = ElCompN(DimName, El) ;
If ( ChildCount <> 0);
y = 1;
While ( y <= ChildCount );
ChildEl = ElComp ( DimName , El, 1);
DimensionElementComponentDelete(DimName, El, ChildEl);
y = y +1 ;
End ;
EndIf ;
i = i + 1 ;
End;

Re: TI process to delete all C elements in a particular hier

Posted: Thu Oct 14, 2010 4:31 am
by jydell
Thanks Jrizk

Your idea to build the alternative (second) hierachy C elements with a flag identifying it later needs deletion was invaluable. (my original approach missed this)

Regards

JD