|
发表于 2014-3-17 03:37:28
|
显示全部楼层
As expected deleting subset elements and looping around to populate on the base of a side MDX subset is much slower then destroying and recreating the subset itself...
I thought I would post the code I end up with as it might help some or get some positive criticism from others
Code: #Drill Target view name
#===========================================================================
View01 = 'Drill GL By Product - Test' ;
#Subset Names (static and temporary)
#===========================================================================
Sub01= 'zti_Drill_ByGL_Product';
Sub01Temp = 'zti_Drill_ByGL_Product_temp';
#Check if subset exists if yes, empty it else create it
#===========================================================================
IF ( SubsetExists ( 'Products', Sub01) = 1 ) ;
SubsetDeleteAllElements( 'Products', Sub01 ) ;
ELSE;
SubsetCreate ( 'Products', Sub01 ) ;
ENDIF;
#Check if subset exists if yes, empty it else create it
#===========================================================================
IF ( SubsetExists ( 'Week', Sub01) = 1 ) ;
SubsetDeleteAllElements( 'Week', Sub01 ) ;
ELSE;
SubsetCreate ( 'Week', Sub01 ) ;
ENDIF;
#GLAcc manipulation
#===========================================================================
#Remove temporary subset from dimension if exists
#===========================================================================
IF ( SubsetExists ( 'Products', Sub01Temp ) = 1 ) ;
SubsetDestroy ( 'Products', Sub01Temp ) ;
ENDIF;
#Create temporary/dynamic subset with MDX
#===========================================================================
SubsetCreatebyMDX ( Sub01Temp,
'{TM1DrillDownMember( {TM1FilterByPattern( {TM1SubsetAll( [Products] )}, "'| Products |'")}, All, Recursive )}') ;
#Copy elements from temporary/dynamic subset to permanent/static subset
#===========================================================================
Count = 1;
nSubsetSize = SubsetGetSize ( 'Products', Sub01Temp ) ;
WHILE ( Count <= nSubsetSize ) ;
Product = SubsetGetElementName ( 'Products', Sub01Temp, Count ) ;
SubsetElementInsert ( 'Products', Sub01,Product, Count ) ;
Count = Count + 1 ;
END ;
#Destroy temporary subset
#===========================================================================
SubsetDestroy ( 'Products', Sub01Temp ) ;
#Assign Alias to subset
#===========================================================================
SubsetAliasSet( 'Products', Sub01, 'Full_Name' ) ;
#Assign static subset to view, and set as row
#===========================================================================
ViewSubsetAssign ( 'GL', View01, 'Products', Sub01 ) ;
ViewRowDimensionSet ( 'GL', View01, 'Products', 1 ) ;
#Week manipulation
#===========================================================================
SubsetElementInsert ( 'Week', Sub01 , Week , 1 ) ;
If ( Attrs( 'BW_Week', Week, 'IsAdjWeek' ) @= 'Yes' ) ;
SubsetElementInsert ( 'Week', Sub01 , ElPar ( 'Week', Week, 1) , 2 ) ;
Else ;
SubsetElementInsert ( 'week', Sub01 , ATTRS( 'Week', Week, 'PriorWeek') , 2 ) ;
SubsetElementInsert ( 'week', Sub01 , ATTRS( 'Week', Week, 'PriorWeek1') , 3 ) ;
SubsetElementInsert ( 'week', Sub01 , ATTRS( 'Week', Week, 'PriorWeek2') , 4 ) ;
SubsetElementInsert ( 'week', Sub01 , ATTRS( 'Week', Week, 'PriorWeek3') , 5 ) ;
EndIF ;
#Assign static subset to view
#===========================================================================
ViewSubsetAssign ( 'GL', View01, 'Week', Sub01 ) ;
ViewColumnDimensionSet ( 'GL', View01, 'week' , 1 ) ;
#Apply Zero Suppress on View
#===========================================================================
ViewSuppressZeroesSet ( 'GL', View01, 1 ) ; |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|