Quantcast
Channel: SQL Server Analysis Services Forum
Viewing all articles
Browse latest Browse all 2472

aggregate gives me the headache

$
0
0

so i understand that Aggregate circumvents solve_order, but this ...

i have a calculated measure which is a sum of some other measures, as simply as

CREATE MEMBER CURRENTCUBE.[Measures].[Value Mnf] as [Measures].[MP_Value_Mnf] + [Measures].[MC_Value_Mnf] + ...

then i have a calculation involving Aggregate as this:

CREATE MEMBER CURRENTCUBE.[Calc].[Calc].[ATC3 share] AS
    [Calc].[Fact] /
    Aggregate(existing [Prod].[ATC].[Atc3].Members, [Calc].[Fact])

this gives me horrible values like million percents. so i decided to add a little trace code:

CREATE MEMBER CURRENTCUBE.[Calc].[Calc].[ATC3 share] AS
    '<' +
    vba!str([Calc].[Fact])+ '/' +
    vba!str(Aggregate(existing [Prod].[ATC].[Atc3].Members, [Calc].[Fact]))+'>'

to see how the calculation actually went. and i got this:

<2606380672/<0/0> <0/0> <0/0> <0/0> <0/0> <0/0> <2606380672/3535757536> <0/0> > 

so it calculated the fact, then it went on and calculated the share for all the summed sub-measures, and added them up, despite i explicitly told it to aggregate the fact, and not the calculation. i don't even understand why it didn't lead to infinite recursion.

for some reason unknown, the thing suddenly gets cool if i change to:

CREATE MEMBER CURRENTCUBE.[Calc].[Calc].[ATC3 share] AS
    [Calc].[Fact] /
    Generate([Calc].[Fact], Aggregate(existing [Prod].[ATC].[Atc3].Members))
and again, i feel like alice in wonderland.


Viewing all articles
Browse latest Browse all 2472

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>