Public default cube views
- Nov. 2, 2014
Introduction
As a follow-up to my previous article on creating views on cubes, I wanted to share similar coding to create Default public views. I will not be the first one to write these kind of loops, nor will I be the last. Therefore, feel free to use the codes below. They are self-explanatory to any serious TM1 user/developer.
Coding
We have the following code in the Prolog section of the process:
# Wim Gielis # https://www.wimgielis.com##### # TI code to create default public cube views # 11/2/2014 #####cDeft = 'Default'; c = 1; While( c <= Dimsiz( '}Cubes' )); vCube = Dimnm( '}Cubes', c ); If( Subst( vCube, 1, 1 ) @<> '}' ); If( ViewExists( vCube, cDeft ) = 0 ); d = 0; While( Long( Tabdim( vCube, d + 1 )) > 0 ); vDim = Tabdim( vCube, d + 1 ); If( d = 0 ); ViewCreate( vCube, cDeft ); ViewExtractSkipCalcsSet( vCube, cDeft, 0 ); ViewExtractSkipRuleValuesSet( vCube, cDeft, 0 ); ViewExtractSkipZeroesSet( vCube, cDeft, 0 ); EndIf; ViewSubsetAssign( vCube, cDeft, vDim, cDeft ); d = d + 1; End; EndIf; EndIf; c = c + 1; End;
As was explained earlier, the Default subset and Default view change names when you change the language of the client interface like TM1 Perspectives. So make sure to update the constant value at the top of the code to match your language.
The code will create a Default view only for the application cubes and it will skip control cubes (any cube starting with }). Please note that the Default subset in every dimension of the cube, is used. In case it does not exist, you will be presented with an error. So make sure every dimension that is used in a cube has a Default public subset. This is best practice anyway. If you cannot be sure this is the case, add some lines of code to check whether the subsets exist. If you do not know how to do so, check out other pages on my website and you will definitely find the answers you need.