- Jun. 10, 2015
While it is not uncommon to have TM1 functions that are undocumented, ahum, one of the more interesting ones is the function SwapAliasWithPrincipalName. It allows you to switch dimension element names with the values of an alias. That way, you can without effort, substitute element names for an alias. For example, because you made a mistake or requirements of the TM1 model have changed. Below I will demonstrate the usage of the function in a TI process.
Said TI process is kind of a bit weird. It allows you to anonymize a cube's elements (therefore also its data). Basically, I will swap the element names with a unique rather random element name. I have yet to find a good usage of this code :-) but one option that comes to mind is when you ask a question at TM1forum.com and the cube's data is confidential information.
I will show you how to:
- loop over the dimensions of a cube
- loop over the elements of a dimension
- populate an alias value
- swap element names and aliases
Using a String parameter pCube for the cubename, we have:
# Wim Gielis # http://www.wimgielis.comc0 = 'random'; If( CubeExists( pCube ) > 0 ); m = 1; While( m > 0); vDim = Tabdim( pCube, m ); If( vDim @<> '' ); AttrInsert( vDim, '', c0, 'A'); e = 1; While( e <= Dimsiz( vDim )); vElem = Dimnm( vDim, e ); AttrPutS( 'Element_' | NumberToString( e ), vDim, vElem, c0 ); e = e + 1; End; SwapAliasWithPrincipalName( vDim, c0, 0 ); m = m + 1; Else; m = 0; EndIf; End; EndIf;
Each element is called "Element_" followed by its unique index number in the dimension. Therefore, all element names are unique in the dimension (but not over dimensions). As we do not delete the original element names (they became alias values), the cube will still function perfectly well. Rules for example will continue to work as before. SwapAliasWithPrincipalName is the keyword here ! Dimension names and cube names could still be made anonymous by setting up a localization in TM1. Not sure if that is worth the effort though. You decide.
If you want to obfuscate the data in a TM1 cube without changing the element names, please have a look here for the (hidden) function DebugUtility.