Hi all,
Is it possible to get all elements in each dimension and put them in one dimension?
If so, how to do it?
Merge all elements into one dimension
-
- MVP
- Posts: 1831
- Joined: Mon Dec 05, 2011 11:51 am
- OLAP Product: Cognos TM1
- Version: PA2.0 and most of the old ones
- Excel Version: All of em
- Location: Manchester, United Kingdom
- Contact:
Re: Merge all elements into one dimension
You can, not sure why you would want to. It would help if you elaborated further with your questions as to the business purpose so that people would be better able to help you.
See a recent post about merging 2 dimensions into 1... the same concept applies for all dimensions you would just need to extend it... I'm also sure that the search box would provide more similar posts:
http://www.tm1forum.com/viewtopic.php?f=3&t=11226
Either way a simple loop of the }Dimensions with another loop inside to cycle the dimension would suffice. Keep in mind that the same element name may exist in multiple dimensions as such you may want to build a cube that flags where they are used e.g.
Note that I have just written the above code in the reply box itself as opposed to in a TI editor so it may have some errors that need to be corrected and I have also left you to work out which part/s should go in which tab of the TI (hint it needs more than 1 tab.)
See a recent post about merging 2 dimensions into 1... the same concept applies for all dimensions you would just need to extend it... I'm also sure that the search box would provide more similar posts:
http://www.tm1forum.com/viewtopic.php?f=3&t=11226
Either way a simple loop of the }Dimensions with another loop inside to cycle the dimension would suffice. Keep in mind that the same element name may exist in multiple dimensions as such you may want to build a cube that flags where they are used e.g.
Code: Select all
sDimName = '}elements';
sDimDim = '}Dimensions';
sCubeName = '}ElementMapper';
sDimMeasures = sCubeName | '_measures';
If ( CubeExists ( sCubeName ) = 0 );
If ( DimensionExists ( sDimName ) = 0 );
DimensionCreate ( sDimName );
EndIf;
If ( DimensionExists ( sDimMeasures ) = 0 );
DimensionCreate ( sDimMeasures );
DimensionElementInsert ( sDimMeasures, '', 'Flag', 'N' );
DimensionElementInsert ( sDimMeasures, '', 'Type', 'S' );
EndIf;
CubeCreate ( sCubeName, sDimDim, sDimName, sDimMeasures );
EndIf;
iCount = 1;
iMax = DimSiz ( sDimDim );
While ( iCount <= iMax );
sDim = DimNm ( sDimDim, iCount );
If ( sDim @<> sDimName );
iSubCount = 1;
iSubMax = DimSiz ( sDim );
While ( iSubCount <= iSubMax );
sElement = DimNm ( sDim, iSubCount );
DimensionElementInsert ( sDimName, '', sElement, 'n' );
iSubCount = iSubCount + 1;
End;
EndIf;
iCount = iCount + 1;
End;
iCount = 1;
iMax = DimSiz ( sDimDim );
While ( iCount <= iMax );
sDim = DimNm ( sDimDim, iCount );
If ( sDim @<> sDimName );
iSubCount = 1;
iSubMax = DimSiz ( sDim );
While ( iSubCount <= iSubMax );
sElement = DimNm ( sDim, iSubCount );
sType = DType ( sDim, sElement );
CellPutN ( 1, sCubeName, sDim, sElement, 'Flag' );
CellPutS ( sType, sCubeName, sDim, sElement, 'Type' );
iSubCount = iSubCount + 1;
End;
EndIf;
iCount = iCount + 1;
End;
Declan Rodger
-
- Posts: 19
- Joined: Fri Nov 21, 2014 5:01 pm
- OLAP Product: tm1
- Version: 10.1
- Excel Version: 2010
Re: Merge all elements into one dimension
I need to get a list of all elements & its attributes from each dimension, then put them all in a cube with the following layout:
DIMENSION NAME ELEMENT Type HTE_DESC HTE_CD WID_Loc WID_LOC_NM
Loc_Seller FTN Simple LOCAL 02 134501 Market China
Loc_Seller USB Simple China 03 17453 Market Africa
Loc_Seller RIT Simple Local 02 186601 Market Europe
CodeBuyer GPS Simple Foreign 12 103541 Market Australia
CodeBuyer UBB Simple China 23 10003 Market Asia
CodeBuyer RMN Simple Local CD 32 134561 Market Canada
My dimension would be DIMENSION NAME and ELEMENT. The rest are measures.
DIMENSION NAME ELEMENT Type HTE_DESC HTE_CD WID_Loc WID_LOC_NM
Loc_Seller FTN Simple LOCAL 02 134501 Market China
Loc_Seller USB Simple China 03 17453 Market Africa
Loc_Seller RIT Simple Local 02 186601 Market Europe
CodeBuyer GPS Simple Foreign 12 103541 Market Australia
CodeBuyer UBB Simple China 23 10003 Market Asia
CodeBuyer RMN Simple Local CD 32 134561 Market Canada
My dimension would be DIMENSION NAME and ELEMENT. The rest are measures.