3 Replies Latest reply: Jan 22, 2015 4:42 AM by Gysbert Wassenaar

# Script

Hi

=

sum({\$<YEAR = {\$(=max(YEAR))},MONTH = {"<=\$(=max({<YEAR={\$(=max(YEAR))}>} MONTH))"}>}

sum(if([PRODUCTION LOCATION]=[SALES LOCATION],

([PRODUCTION FOB QTY]+([PRODUCTION SUB QTY]*(-1)))*([FOB WITHOUT COMMISSION]/[PACK QTY]),

0)

+

sum([PRODUCTION SUB QTY]*[SUB CM])))

• ###### Re: Script

If you nest aggregation functions like sum then you need to use the aggr function to specify over which dimensions the inner sum should be aggregated.

=sum({\$<YEAR = {\$(=max(YEAR))},MONTH = {"<=\$(=max({<YEAR={\$(=max(YEAR))}>} MONTH))"}>}

aggr(sum(if([PRODUCTION LOCATION]=[SALES LOCATION],

([PRODUCTION FOB QTY]+([PRODUCTION SUB QTY]*(-1)))*([FOB WITHOUT COMMISSION]/[PACK QTY]),0)

+ aggr(sum([PRODUCTION SUB QTY]*[SUB CM]),DimP,DimQ,...,DimY),DimA,DimB,...,DimX))

• ###### Re: Script

Hi,

i think i have not communicated properly, actual issue is how do i calculate only for YEAR=2015

(sum(if([PRODUCTION LOCATION]=[SALES LOCATION],

([PRODUCTION FOB QTY]+([PRODUCTION SUB QTY]*(-1)))

*([FOB WITHOUT COMMISSION]/[PACK QTY]),0))

+

sum([PRODUCTION SUB QTY]*[SUB CM])))

• ###### Re: Script

Add {<YEAR={2015}>} to each aggregation function. For example sum(Amount) would become sum( {<YEAR={2015}>} Amount)