MDX script to scope on all but the leaf levels

Hi,

I am trying to specify a scope statement on all non-leaves members of all hierarchies of a dimension (time dimension basically) so I would need to say something like this:

scope (MyMeasure, not leaves(TimeByDay));
   this = (MyMeasure,timeByDay.currentHierarchy.currentmember.firstChild);
end scope;

Does anybody see a way of doing this without explicitly repeating a scope statement for each implemented hierarchy.level-above-leaf like the one below

scope (
      {[Measures].[RG Queue State],[Measures].[RQ Distinct Queue State]},
      [Processed Statistics Period].[YMD].[Month of year],
      [Processed Statistic Type].[Processed Statistic].[Processed Statistic Action].&[1.]);

this = ([Processed Statistics Period].[YMD].currentmember.FirstChild);

end scope;


Thanks




Answer this question

MDX script to scope on all but the leaf levels

  • lcubian

    Hi Zoran,

    What you should be able to do is to scope your calculation on the All Member of the granuarity attribute of your dimension. So if the granularity attribute of your TimeByDay dimension is Month, then 

       SCOPE([MEASURES].[MYMEASURE], [TIMEBYDAY].[MONTH].[ALL]);
          THIS={EXISTING([TIMEBYDAY].[MONTH].[MONTH].MEMBERS)}.ITEM(0).ITEM(0);
       END SCOPE;

    should do the job of returning the first month that exists with every member on every attribute of the dimension, which is what you want to do I think. Does this work for you Is the performance ok

    Chris

  • dlypka

    I'm not sure of your particular implementation, but have you considered inverting the problem. Something like:

    a) Set the aggregation method for your measure to FirstChild
    b) If necessary, redefine the aggregation at the leaves level:

       Scope (myMeasure, leaves(TimeByDay));
          this  = custom aggregation;
       end scope;


  • Iago

    using leaves in the scope statement makes the performance go waaaay down...

  • MDX script to scope on all but the leaf levels