Zero-out data in TM1 cube
Posted: Wed Jul 07, 2010 3:41 am
Hi All,
Please advise me the procedure to zero-out the data in TM1 Cube.
Regards,
Ravi
Please advise me the procedure to zero-out the data in TM1 Cube.
Regards,
Ravi
Discussing all things TM1, Planning Analytics, PAx and PAW
https://www.tm1forum.com/
Option 1: Create a view of the data at N level. Type a zero into every cell.ravi wrote: Please advise me the procedure to zero-out the data in TM1 Cube.
Look for ViewExtractSkipCalcsSet (and its related function, ViewExtractSkipRuleValuesSet) in the TM1 TurboIntegrator Functions section of the TM1 Reference Guide.craig_karr wrote:If you go with option three, is it so that you have to create a view that actually displays all the values on N level that you want to zero out? I have tried to do that but the view gets way to big when I nest several large dimensions so TM1 crashes. In that case is my only option to create several views and then write a turbointegrator process to zero out each of them?
I guess there is no way that you can zero out a view with consolidated elements with the turbointegrator option?
Hi Sachin,sachin wrote:I am currently using these 2 lines in rules to zero-out data -
[] = S: ('');
[] = N: 0;
Whenever I have to zero out data, I add these 2 lines to the beginning of my rules code (just after feedstrings and skipcheck). We are working with strings in our cube and hence the 1st line of the rule.
I did not see any one recommending this (using the rule approach)! I am new to TM1 and sometimes don't understand the pitfalls of my approach; is this approach undesirable? Please share your thoughts. Thanks.
- Sachin
Code: Select all
CubeSetLogChanges('WekoMCP', 0);
ViewExtractSkipCalcsSet ('WekoMCP', 'AllBillData', 1);
ViewZeroOut('MCPWeko', 'AllBillData');
CubeSetLogChanges('WekoMCP', 1);
Code: Select all
#=========================================================
# Declare variables
#=========================================================
sView = 'zero_out';
sSub = 'zero_out';
#=========================================================
# Trim Input Values
#=========================================================
pCube = TRIM( pCube );
pDim1 = TRIM( pDim1 );
pDim2 = TRIM( pDim2 );
pDim3 = TRIM( pDim3 );
pDim4 = TRIM( pDim4 );
pDim5 = TRIM( pDim5 );
pDim6 = TRIM( pDim6 );
pDim7 = TRIM( pDim7 );
pDim8 = TRIM( pDim8 );
pDim9 = TRIM( pDim9 );
pDim10 = TRIM( pDim10 );
pVal1 = TRIM( pVal1 );
pVal2 = TRIM( pVal2 );
pVal3 = TRIM( pVal3 );
pVal4 = TRIM( pVal4 );
pVal5 = TRIM( pVal5 );
pVal6 = TRIM( pVal6 );
pVal7 = TRIM( pVal7 );
pVal8 = TRIM( pVal8 );
pVal9 = TRIM( pVal9 );
pVal10 = TRIM( pVal10 );
#=========================================================
# Check if cube exits
#=========================================================
If( DIMIX( '}Cubes', pCube ) = 0 );
ASCIIOutput( sLog, 'Cube '| pCube |' does not exist on the server.' );
ProcessError;
endif;
#=========================================================
# Verify dimensions are part for the cube specified.
#=========================================================
nChkCount = 0;
nDimCount = 0;
If( pDim1 @<> '' ); nDimCount = nDimCount + 1; endif;
If( pDim2 @<> '' ); nDimCount = nDimCount + 1; endif;
If( pDim3 @<> '' ); nDimCount = nDimCount + 1; endif;
If( pDim4 @<> '' ); nDimCount = nDimCount + 1; endif;
If( pDim5 @<> '' ); nDimCount = nDimCount + 1; endif;
If( pDim6 @<> '' ); nDimCount = nDimCount + 1; endif;
If( pDim7 @<> '' ); nDimCount = nDimCount + 1; endif;
If( pDim8 @<> '' ); nDimCount = nDimCount + 1; endif;
If( pDim9 @<> '' ); nDimCount = nDimCount + 1; endif;
If( pDim10 @<> '' ); nDimCount = nDimCount + 1; endif;
nChkDim = 1;
sChkDim = TABDIM( pCube, nChkDim );
While( sChkDim @<> '' );
If( pDim1 @= sChkDim ); nChkCount = nChkCount + 1;
elseif( pDim2 @= sChkDim ); nChkCount = nChkCount + 1;
elseif( pDim3 @= sChkDim ); nChkCount = nChkCount + 1;
elseif( pDim4 @= sChkDim ); nChkCount = nChkCount + 1;
elseif( pDim5 @= sChkDim ); nChkCount = nChkCount + 1;
elseif( pDim6 @= sChkDim ); nChkCount = nChkCount + 1;
elseif( pDim7 @= sChkDim ); nChkCount = nChkCount + 1;
elseif( pDim8 @= sChkDim ); nChkCount = nChkCount + 1;
elseif( pDim9 @= sChkDim ); nChkCount = nChkCount + 1;
elseif( pDim10 @= sChkDim ); nChkCount = nChkCount + 1; endif;
nChkDim = nChkDim + 1;
sChkDim = TABDIM( pCube, nChkDim );
END;
If( nDimCount <> nChkCount );
ASCIIOutput( sLog, 'You have entered a value for '| NumberToString( nDimCount ) |' of the dimension parameters.' );
ASCIIOutput( sLog, 'Only '| NumberToString( nChkCount ) |' out of the '| NumberToString( nDimCount ) |' dimension(s) exist(s) in the '| pCube |' cube.' );
ProcessError;
endif;
#=========================================================
# Check if View exists and destroy it if it does
# Create View
#=========================================================
If( ViewExists( pCube, sView ) = 1 );
ViewDestroy( pCube, sView );
endif;
ViewCreate( pCube, sView );
#=========================================================
# Check if dimension exists on the server,
# Destroy subset,
# Create if member exists in the dimension,
# A null value for member name will create an all subset.
# Create subset.
# Any incorrect value will cause process to quit.
#=========================================================
If( DimensionExists( pDim1 ) = 1 );
If( SubsetExists( pDim1, sSub ) = 1 );
SubsetDestroy( pDim1, sSub );
endif;
If( DIMIX( pDim1, pVal1 ) > 0 );
SubsetCreateByMDX( sSub, '{TM1DRILLDOWNMEMBER( {['| pDim1 |'].['| pVal1 |']}, ALL, RECURSIVE )}' );
ViewSubsetAssign( pCube, sView, pDim1, sSub );
elseif( pVal1 @= '' );
SubsetCreateByMDX( sSub, '{TM1SUBSETALL( ['| pDim1 |'] )}' );
ViewSubsetAssign( pCube, sView, pDim1, sSub );
else;
ASCIIOutput( sLog, 'The member '| pVal1 |' does not exist in dimension '| pDim1 |'.' );
ProcessError;
endif;
elseif( pDim1 @= '' );
elseif( DimensionExists( pDim1 ) = 0 );
ASCIIOutput( sLog, 'Dimension '| pDim1 |' does not exist on the server.' );
ProcessError;
endif;
If( DimensionExists( pDim2 ) = 1 );
If( SubsetExists( pDim2, sSub ) = 1 );
SubsetDestroy( pDim2, sSub );
endif;
If( DIMIX( pDim2, pVal2 ) > 0 );
SubsetCreateByMDX( sSub, '{TM1DRILLDOWNMEMBER( {['| pDim2 |'].['| pVal2 |']}, ALL, RECURSIVE )}' );
ViewSubsetAssign( pCube, sView, pDim2, sSub );
elseif( pVal2 @= '' );
SubsetCreateByMDX( sSub, '{TM1SUBSETALL( ['| pDim2 |'] )}' );
ViewSubsetAssign( pCube, sView, pDim2, sSub );
else;
ASCIIOutput( sLog, 'The member '| pVal2 |' does not exist in dimension '| pDim2 |'.' );
ProcessError;
endif;
elseif( pDim2 @= '' );
elseif( DimensionExists( pDim2 ) = 0 );
ASCIIOutput( sLog, 'Dimension '| pDim2 |' does not exist on the server.' );
ProcessError;
endif;
If( DimensionExists( pDim3 ) = 1 );
If( SubsetExists( pDim3, sSub ) = 1 );
SubsetDestroy( pDim3, sSub );
endif;
If( DIMIX( pDim3, pVal3 ) > 0 );
SubsetCreateByMDX( sSub, '{TM1DRILLDOWNMEMBER( {['| pDim3 |'].['| pVal3 |']}, ALL, RECURSIVE )}' );
ViewSubsetAssign( pCube, sView, pDim3, sSub );
elseif( pVal3 @= '' );
SubsetCreateByMDX( sSub, '{TM1SUBSETALL( ['| pDim3 |'] )}' );
ViewSubsetAssign( pCube, sView, pDim3, sSub );
else;
ASCIIOutput( sLog, 'The member '| pVal3 |' does not exist in dimension '| pDim3 |'.' );
ProcessError;
endif;
elseif( pDim3 @= '' );
elseif( DimensionExists( pDim3 ) = 0 );
ASCIIOutput( sLog, 'Dimension '| pDim3 |' does not exist on the server.' );
ProcessError;
endif;
If( DimensionExists( pDim4 ) = 1 );
If( SubsetExists( pDim4, sSub ) = 1 );
SubsetDestroy( pDim4, sSub );
endif;
If( DIMIX( pDim4, pVal4 ) > 0 );
SubsetCreateByMDX( sSub, '{TM1DRILLDOWNMEMBER( {['| pDim4 |'].['| pVal4 |']}, ALL, RECURSIVE )}' );
ViewSubsetAssign( pCube, sView, pDim4, sSub );
elseif( pVal4 @= '' );
SubsetCreateByMDX( sSub, '{TM1SUBSETALL( ['| pDim4 |'] )}' );
ViewSubsetAssign( pCube, sView, pDim4, sSub );
else;
ASCIIOutput( sLog, 'The member '| pVal4 |' does not exist in dimension '| pDim4 |'.' );
ProcessError;
endif;
elseif( pDim4 @= '' );
elseif( DimensionExists( pDim4) = 0 );
ASCIIOutput( sLog, 'Dimension '| pDim4 |' does not exist on the server.' );
ProcessError;
endif;
If( DimensionExists( pDim5 ) = 1 );
If( SubsetExists( pDim5, sSub ) = 1 );
SubsetDestroy( pDim5, sSub );
endif;
If( DIMIX( pDim5, pVal5 ) > 0 );
SubsetCreateByMDX( sSub, '{TM1DRILLDOWNMEMBER( {['| pDim5 |'].['| pVal5 |']}, ALL, RECURSIVE )}' );
ViewSubsetAssign( pCube, sView, pDim5, sSub );
elseif( pVal5 @= '' );
SubsetCreateByMDX( sSub, '{TM1SUBSETALL( ['| pDim5 |'] )}' );
ViewSubsetAssign( pCube, sView, pDim5, sSub );
else;
ASCIIOutput( sLog, 'The member '| pVal5 |' does not exist in dimension '| pDim5 |'.' );
ProcessError;
endif;
elseif( pDim5 @= '' );
elseif( DimensionExists( pDim5 ) = 0 );
ASCIIOutput( sLog, 'Dimension '| pDim5 |' does not exist on the server.' );
ProcessError;
endif;
If( DimensionExists( pDim6 ) = 1 );
If( SubsetExists( pDim6, sSub ) = 1 );
SubsetDestroy( pDim6, sSub );
endif;
If( DIMIX( pDim6, pVal6 ) > 0 );
SubsetCreateByMDX( sSub, '{TM1DRILLDOWNMEMBER( {['| pDim6 |'].['| pVal6 |']}, ALL, RECURSIVE )}' );
ViewSubsetAssign( pCube, sView, pDim6, sSub );
elseif( pVal6 @= '' );
SubsetCreateByMDX( sSub, '{TM1SUBSETALL( ['| pDim6 |'] )}' );
ViewSubsetAssign( pCube, sView, pDim6, sSub );
else;
ASCIIOutput( sLog, 'The member '| pVal6 |' does not exist in dimension '| pDim6 |'.' );
ProcessError;
endif;
elseif( pDim6 @= '' );
elseif( DimensionExists( pDim6 ) = 0 );
ASCIIOutput( sLog, 'Dimension '| pDim6 |' does not exist on the server.' );
ProcessError;
endif;
If( DimensionExists( pDim7 ) = 1 );
If( SubsetExists( pDim7, sSub ) = 1 );
SubsetDestroy( pDim7, sSub );
endif;
If( DIMIX( pDim7, pVal7 ) > 0 );
SubsetCreateByMDX( sSub, '{TM1DRILLDOWNMEMBER( {['| pDim7 |'].['| pVal7 |']}, ALL, RECURSIVE )}' );
ViewSubsetAssign( pCube, sView, pDim7, sSub );
elseif( pVal7 @= '' );
SubsetCreateByMDX( sSub, '{TM1SUBSETALL( ['| pDim7 |'] )}' );
ViewSubsetAssign( pCube, sView, pDim7, sSub );
else;
ASCIIOutput( sLog, 'The member '| pVal7 |' does not exist in dimension '| pDim7 |'.' );
ProcessError;
endif;
elseif( pDim7 @= '' );
elseif( DimensionExists( pDim7 ) = 0 );
ASCIIOutput( sLog, 'Dimension '| pDim7 |' does not exist on the server.' );
ProcessError;
endif;
If( DimensionExists( pDim8 ) = 1 );
If( SubsetExists( pDim8, sSub ) = 1 );
SubsetDestroy( pDim8, sSub );
endif;
If( DIMIX( pDim8, pVal8 ) > 0 );
SubsetCreateByMDX( sSub, '{TM1DRILLDOWNMEMBER( {['| pDim8 |'].['| pVal8 |']}, ALL, RECURSIVE )}' );
ViewSubsetAssign( pCube, sView, pDim8, sSub );
elseif( pVal8 @= '' );
SubsetCreateByMDX( sSub, '{TM1SUBSETALL( ['| pDim8 |'] )}' );
ViewSubsetAssign( pCube, sView, pDim8, sSub );
else;
ASCIIOutput( sLog, 'The member '| pVal8 |' does not exist in dimension '| pDim8 |'.' );
ProcessError;
endif;
elseif( pDim8 @= '' );
elseif( DimensionExists( pDim8 ) = 0 );
ASCIIOutput( sLog, 'Dimension '| pDim8 |' does not exist on the server.' );
ProcessError;
endif;
If( DimensionExists( pDim9 ) = 1 );
If( SubsetExists( pDim9, sSub ) = 1 );
SubsetDestroy( pDim9, sSub );
endif;
If( DIMIX( pDim9, pVal9 ) > 0 );
SubsetCreateByMDX( sSub, '{TM1DRILLDOWNMEMBER( {['| pDim9 |'].['| pVal9 |']}, ALL, RECURSIVE )}' );
ViewSubsetAssign( pCube, sView, pDim9, sSub );
elseif( pVal9 @= '' );
SubsetCreateByMDX( sSub, '{TM1SUBSETALL( ['| pDim9 |'] )}' );
ViewSubsetAssign( pCube, sView, pDim9, sSub );
else;
ASCIIOutput( sLog, 'The member '| pVal9 |' does not exist in dimension '| pDim9 |'.' );
ProcessError;
endif;
elseif( pDim9 @= '' );
elseif( DimensionExists( pDim9 ) = 0 );
ASCIIOutput( sLog, 'Dimension '| pDim9 |' does not exist on the server.' );
ProcessError;
endif;
If( DimensionExists( pDim10 ) = 1 );
If( SubsetExists( pDim10, sSub ) = 1 );
SubsetDestroy( pDim10, sSub );
endif;
If( DIMIX( pDim10, pVal10 ) > 0 );
SubsetCreateByMDX( sSub, '{TM1DRILLDOWNMEMBER( {['| pDim10 |'].['| pVal10 |']}, ALL, RECURSIVE )}' );
ViewSubsetAssign( pCube, sView, pDim10, sSub );
elseif( pVal10 @= '' );
SubsetCreateByMDX( sSub, '{TM1SUBSETALL( ['| pDim10 |'] )}' );
ViewSubsetAssign( pCube, sView, pDim10, sSub );
else;
ASCIIOutput( sLog, 'The member '| pVal10 |' does not exist in dimension '| pDim10 |'.' );
ProcessError;
endif;
elseif( pDim10 @= '' );
elseif( DimensionExists( pDim10 ) = 0 );
ASCIIOutput( sLog, 'Dimension '| pDim10 |' does not exist on the server.' );
ProcessError;
endif;
#=========================================================
# Turn off Cube logging
# Clear View
#=========================================================
CUBESETLOGCHANGES( pCube, 0 );
ViewZeroOut( pCube, sView );
CUBESETLOGCHANGES( pCube, 1 );
Code: Select all
#=========================================================
# Remove dymanic objects
#=========================================================
ViewDestroy( pCube, sView );
If( SubsetExists( pDim1, sSub ) = 1 );
SubsetDestroy( pDim1, sSub );
endif;
If( SubsetExists( pDim2, sSub ) = 1 );
SubsetDestroy( pDim2, sSub );
endif;
If( SubsetExists( pDim3, sSub ) = 1 );
SubsetDestroy( pDim3, sSub );
endif;
If( SubsetExists( pDim4, sSub ) = 1 );
SubsetDestroy( pDim4, sSub );
endif;
If( SubsetExists( pDim5, sSub ) = 1 );
SubsetDestroy( pDim5, sSub );
endif;
If( SubsetExists( pDim6, sSub ) = 1 );
SubsetDestroy( pDim6, sSub );
endif;
If( SubsetExists( pDim7, sSub ) = 1 );
SubsetDestroy( pDim7, sSub );
endif;
If( SubsetExists( pDim8, sSub ) = 1 );
SubsetDestroy( pDim8, sSub );
endif;
If( SubsetExists( pDim9, sSub ) = 1 );
SubsetDestroy( pDim9, sSub );
endif;
If( SubsetExists( pDim10, sSub ) = 1 );
SubsetDestroy( pDim10, sSub );
endif;
Code: Select all
Cubecount = DIMSIZ('Dim with cube names');
i = 1;
# loop for all cubes in dim
While (i <= Cubecount);
CubeName = DIMNM ('Dim with cube names', i );
if ( ViewExists (CubeName, 'ZEROOUT') = 1 );
ViewDestroy(CubeName, 'ZEROOUT');
endif;
#create view with all dimesions in cube
ViewCreate(CubeName, 'Zeroout');
#zap data
ViewZeroOut(CubeName, 'Zeroout');
if ( ViewExists (CubeName, 'ZEROOUT') = 1 );
ViewDestroy(CubeName, 'ZEROOUT');
endif;
#next cube in dim
i = i + 1;
end;