Page 1 of 1

Empty Dimension in TI Process

Posted: Sat Jun 13, 2009 7:48 am
by damientaylorcreata
Hi Guys,

Can anybody please let me know how to delete (Clear / Purge) all elements from a dimension:

a) via a manual process in Perspectives. I am unable to see an option that says delete all, empty or clear elements.

b) is there a command I can use within TI to empty all elements before importing the new elements.

I have tried looking through the documentation, but I am unable to find an answer.

Thanks

Re: Empty Dimension in TI Process

Posted: Sat Jun 13, 2009 7:54 am
by Alan Kirk
damientaylorcreata wrote:Hi Guys,

Can anybody please let me know how to delete (Clear / Purge) all elements from a dimension:

a) via a manual process in Perspectives. I am unable to see an option that says delete all, empty or clear elements.

b) is there a command I can use within TI to empty all elements before importing the new elements.

I have tried looking through the documentation, but I am unable to find an answer.
Search for the TurboIntegrator function DimensionDeleteAllElements.

According to the help if you recreate any existing elements in the same Metadata tab, then any cubes which use the dimensions will retain their data after the dimension is rebuilt.

I'm not sure I'd trust that (anything that can go wrong, etc), but if you want to dump the data as well this will do it for you. It depends on what your intention is.

Re: Empty Dimension in TI Process

Posted: Sat Jun 13, 2009 8:05 am
by damientaylorcreata
Hi Alan,

That was a quick reply and yes I have found the function: "DimensionDeleteAllElements"

Thanks
Damien

Re: Empty Dimension in TI Process

Posted: Sat Jun 13, 2009 9:01 am
by Martin Ryan
To echo Alan's warning, if your dimension rebuild fails for whatever reason, then you can potentially lose a lot of data.

In order to get around this, I would recommend a different approach, which is cycling through the dimension in the prolog and deleting all the consolidated elements, effectively removing your hierarchy, but leaving the N level elements intact. Then rebuild your hierarchy in the metadata tab, based on your source.

An optional extra is to call a process from the Epilog that cycles through the dimension and puts any orphans into an "Orphan" consolidation so you can check that the rebuild went successfully.

This means if it goes pear shaped then you will not lose any data, just the hierarchy.

Martin

Re: Empty Dimension in TI Process

Posted: Sat Jun 13, 2009 9:06 am
by Martin Ryan
The function for my method, by the way, is DimensionElementComponentDelete. Some sample, untested code below

Note that when deleting elements it's best to start at the end of a dimension and work your way backwards, otherwise what was element n becomes element n-1 when you delete a preceding element. This means you can skip over elements easily.

Code: Select all

myDim='DimToPurge';
i=dimsiz(myDim);
while(i>0);
elem=dimnm(myDim, i);
numChild=elcompn(myDim, elem);
while(numChild>0);
  sChild=elcomp(myDim, elem, numChild);
  DimensionElementComponentDelete(myDim, elem, sChild);
  numChild=numChild-1;
end;
i=i-1;
end;