Using ELLEV on consolidation with nested consolidations

Post Reply
MikeF
Posts: 11
Joined: Wed Jan 28, 2015 6:22 am
OLAP Product: Cognos Express
Version: 10.2
Excel Version: 2010

Using ELLEV on consolidation with nested consolidations

Post by MikeF »

Hi all,

I'm trying to create a subset containing only level 0 elements from a consolidation in a TI process using the following code:

Code: Select all

## Build branch subset ##
vString = 'Trading Branches';
Dim = 'Branch';
If (SubsetExists(Dim,vPrefix)=1);
  SubsetDeleteAllElements(Dim,vPrefix);
Else;
   SubsetCreate(Dim,vPrefix);
Endif;

vCounter =1;
vNumberOfComponents = ELCOMPN(Dim, vString);
WHILE (vCounter <= vNumberOfComponents);
    IF (ELLEV (Dim, ELCOMP(Dim,vString, vCounter)) = 0);
          SubsetElementInsert(Dim, vPrefix, ELCOMP(Dim,vString, vCounter),1);
    ENDIF;
    vCounter= vCounter +1;
END;
What I end up with is a subset with only a couple of elements which are the only N level elements one level down from the top level consolidation in it. All the other N level items that are further down a hierarchy of consolidations are missing.

What am I missing here? I expected the combination of ELLEV and ELCOMP to go through all items in the subset hierarchy tree, but it only seems to do one level? If that's just how it works how best would I get what I'm after?
Last edited by MikeF on Wed Jan 28, 2015 8:55 pm, edited 2 times in total.
declanr
MVP
Posts: 1831
Joined: Mon Dec 05, 2011 11:51 am
OLAP Product: Cognos TM1
Version: PA2.0 and most of the old ones
Excel Version: All of em
Location: Manchester, United Kingdom
Contact:

Re: Using ELLEV on subset with folded consolidations

Post by declanr »

ElComp only bring back direct components; you can either elaborate your code to do elcomps within elcomps or:
1/ Just create the subset by MDX - you can even get the code you need from a fairly quick use of the wizard then throw it in your TI (if you don't know how to write it neatly.)
2/ Loop all n-level elements in the dimension and use elisanc to work out whether it is an ANCESTOR (as opposed to child) of the consolidated element.

Or probably a few other things but that's a simple starter for ten.
Declan Rodger
MikeF
Posts: 11
Joined: Wed Jan 28, 2015 6:22 am
OLAP Product: Cognos Express
Version: 10.2
Excel Version: 2010

Re: Using ELLEV on consolidation with nested consolidations

Post by MikeF »

Oh yeah. Updated to use SubsetCreateByMDX and it's all good.

Thanks for the nudge!

Mike
Post Reply