Recursive Subset Creation
Posted: Thu Oct 11, 2012 3:56 pm
Guys,
Below is the code for process that give you the ability to create a subset based on the children of a consolidation. You can limit the subset to x number of levels below the parent and you can also ignore the parent. Due to the way it is built you can stack multiple versions within the same subset:
This has been helpful when creating subsets within views for data sources. As MDX subsets lock servers when they are used within a view for say exporting data, this works around the issue without having to create an MDX subset and copy it to another static subset,
I hope it proves useful,
Jim.
Below is the code for process that give you the ability to create a subset based on the children of a consolidation. You can limit the subset to x number of levels below the parent and you can also ignore the parent. Due to the way it is built you can stack multiple versions within the same subset:
Code: Select all
### Parameters
pSubset: string
pDim: string
pParentElem: string
pElem: string
pLvl: number
pLimit: number
pIgnore: string
#Always pass pSubset, pDim, pParentElem (send blank), pElem and pLvl
#Optional: pLimit and pIgnore
### Prolog
# Written by Jim Wood
# 10/11/2012
i=ELCOMPN(pDim, pElem);
WHILE(i>0);
IF((pLimit=0) % (pLimit>pLvl));
ExecuteProcess(
'RAD_SUBSET_create_recursively_lvl_limit',
'pSubset', pSubset,
'pDim', pDim,
'pParentElem', pElem,
'pElem', ELCOMP(pDim,pElem,i),
'pLvl', pLvl+1,
'pLimit', pLimit,
'pIgnore',''
);
EndIF;
i=i-1;
END;
IF(pElem@<>pIgnore);
SubSetElementInsert(pDim,pSubset,pElem,1);
EndIF;
I hope it proves useful,
Jim.