Hi,
We have gone live, but previously in development I was using DimensionDeleteAllElements('Dim'); in Epilog of a dim build to tidy up the dimensions as we progressed. Now I have removed this I am wondering whether there is a need to use if(DIMIX(Element) = 1); then do not proceed with DIMENSIONELEMENTINSERT, due to the fact its already created but mostly I am concerned it will override, lose data? I have tested and it doesnt seem to be an issue not having DIMIX, but just would like a bit of confirmation.
Cheers
G
Building Dimension without deleting data
-
- Site Admin
- Posts: 6647
- Joined: Sun May 11, 2008 2:30 am
- OLAP Product: TM1
- Version: PA2.0.9.18 Classic NO PAW!
- Excel Version: 2013 and Office 365
- Location: Sydney, Australia
- Contact:
Re: Building Dimension without deleting data
1/ I'm not sure why you would be using DimensionDeleteAllElements in an Epilog; indeed I wouldn't recommend using it at all outside of a process which merely deletes and recreates a test structure. That thing is dangerous.BigG wrote: We have gone live, but previously in development I was using DimensionDeleteAllElements('Dim'); in Epilog of a dim build to tidy up the dimensions as we progressed. Now I have removed this I am wondering whether there is a need to use if(DIMIX(Element) = 1); then do not proceed with DIMENSIONELEMENTINSERT, due to the fact its already created but mostly I am concerned it will override, lose data? I have tested and it doesnt seem to be an issue not having DIMIX, but just would like a bit of confirmation.
2/ (DIMIX(Element) = 1) will be true for only a single element. If you were to do such a test, it would be >0 rather than =1.
3/ You don't need to worry about it. If the element already exists then DimensionElementInsert won't do anything. We do that all the time. However I do sometimes do the DimIx test anyway; when it's 0 I export details of the element to a log file via AsciiOutput to give me a heads up that there's a new kid in town. However it definitely isn't necessary to do it before doing the Insert.
For the sake of completeness only, I'll mention that the function that has a risk of costing you data is DimensionElementComponentAdd. If you use that to add a child to an N level element it automatically converts to a C level one, then it's buh-bye to any data stored in it.
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
-
- Community Contributor
- Posts: 211
- Joined: Tue Sep 15, 2009 11:13 pm
- OLAP Product: IBMPA
- Version: PA 2.0 Cloud
- Excel Version: 2010
Re: Building Dimension without deleting data
thanks Alan for quick response
THanks again.. G
sorry didnt explain, was only used during dev and testing, not part of production1/ I'm not sure why you would be using DimensionDeleteAllElements in an Epilog; indeed I wouldn't recommend using it at all outside of a process which merely deletes and recreates a test structure. That thing is dangerous.
noted2/ (DIMIX(Element) = 1) will be true for only a single element. If you were to do such a test, it would be >0 rather than =1.
great, just what I wanted3/ You don't need to worry about it. If the element already exists then DimensionElementInsert won't do anything. We do that all the time. However I do sometimes do the DimIx test anyway; when it's 0 I export details of the element to a log file via AsciiOutput to give me a heads up that there's a new kid in town. However it definitely isn't necessary to do it before doing the Insert.
yes good point, will test and retest the dimensions and ensure no data carrying leaf nodes are potentially rolled up intoFor the sake of completeness only, I'll mention that the function that has a risk of costing you data is DimensionElementComponentAdd.
THanks again.. G
GG
-
- Posts: 16
- Joined: Tue Mar 29, 2011 12:47 pm
- OLAP Product: TM1/Cognos Express
- Version: 9.5.1 - 10.2
- Excel Version: 2003-2013
Re: Building Dimension without deleting data
What you could consider is following this sort of approach:
Rather than deleting all the existing elements, you could "unwind" the dimensions consolidations and rebuild it based on the definitions of the data source, if it's changed:
dim='your dimension';
i = dimsiz(dim);
x=1;
While(x<=i);
vEl=dimnm(dim,x);
y=elcompn(dim,vEl);
While(y>0);
dimensionelementcomponentdelete(dim,vEl,elcomp(dim,vEl,y));
y=y-1;
End;
x=x+1;
if(x>dimsiz(dim)+100);processquit;endif;
End;
That way you wont lose any elements that existed before, and new ones will be added, and existing ones put into hierachy based on the new state of the datasource.
Elements not in the data source will not be added to a consolidation, so you might want to make a consolidation holder for them, called something like "orphans" and create a little process to dropping them in there too.
Rather than deleting all the existing elements, you could "unwind" the dimensions consolidations and rebuild it based on the definitions of the data source, if it's changed:
dim='your dimension';
i = dimsiz(dim);
x=1;
While(x<=i);
vEl=dimnm(dim,x);
y=elcompn(dim,vEl);
While(y>0);
dimensionelementcomponentdelete(dim,vEl,elcomp(dim,vEl,y));
y=y-1;
End;
x=x+1;
if(x>dimsiz(dim)+100);processquit;endif;
End;
That way you wont lose any elements that existed before, and new ones will be added, and existing ones put into hierachy based on the new state of the datasource.
Elements not in the data source will not be added to a consolidation, so you might want to make a consolidation holder for them, called something like "orphans" and create a little process to dropping them in there too.