Recursive Subset Creation

Ideas and tips for enhancing your TM1 application
Post Reply
User avatar
jim wood
Site Admin
Posts: 3951
Joined: Wed May 14, 2008 1:51 pm
OLAP Product: TM1
Version: PA 2.0.7
Excel Version: Office 365
Location: 37 East 18th Street New York
Contact:

Recursive Subset Creation

Post by jim wood »

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.
Shop at Amazon
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
Post Reply