Recursive Subset Creation

Ideas and tips for enhancing your TM1 application
Post Reply
User avatar
jim wood
Site Admin
Posts: 3693
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

Recursive Subset Creation

Post by jim wood » Thu Oct 11, 2012 3:56 pm


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);
    IF((pLimit=0) % (pLimit>pLvl));
        'pSubset', pSubset,
        'pDim', pDim,
        'pParentElem', pElem,
        'pElem', ELCOMP(pDim,pElem,i),
        'pLvl', pLvl+1,
        'pLimit', pLimit,

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,

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