Page 1 of 1

Using ELLEV on consolidation with nested consolidations

Posted: Wed Jan 28, 2015 8:37 pm
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?

Re: Using ELLEV on subset with folded consolidations

Posted: Wed Jan 28, 2015 8:54 pm
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.

Re: Using ELLEV on consolidation with nested consolidations

Posted: Wed Jan 28, 2015 9:11 pm
by MikeF
Oh yeah. Updated to use SubsetCreateByMDX and it's all good.

Thanks for the nudge!

Mike