Recursive Subset Creation

Ideas and tips for enhancing your TM1 application
Post Reply
User avatar
jim wood
Site Admin
Posts: 3577
Joined: Wed May 14, 2008 1:51 pm
OLAP Product: TM1
Version: TM1 10.2.2
Excel Version: 2007
Location: 1639 Route 10, Suite 107, Parsippany, NJ, USA
Contact:

Recursive Subset Creation

Post by jim wood » 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:

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;
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.
Struggling through the quagmire of life to reach the other side of who knows where.
Application Consulting Group (ACG) TM1 Consulting
OS: Windows 10 64-bit. TM1 Version: 10.2.2

Post Reply