5 Replies Latest reply: Jun 23, 2015 8:45 AM by Stefan Wühl

# sum added with another sum

I need to create an expression as follows:

sum (if ((sum (VALOR_X) / SUM (VALOR_Y)) * 100 <25, QTY).

It does not give error in syntax, but does not return the information.

How can I do this?

Can anyone help me?

• ###### Re: sum added with another sum

Just need to add a closing bracket at the end:

sum (if ( (sum (VALOR_X) / SUM (VALOR_Y)) * 100 <25, QTY))

• ###### Re: sum added with another sum

Stefan, Isn't this a nested aggregation -- that requires an aggr()?

-Rob

• ###### Re: sum added with another sum

Oh, yes!

Must have been blinded ...

Dozetech, where / in which context are you using this expression? As Rob correctly said, you need to use advanced aggregation to be able to embed an aggregation function linke sum() into  another aggregation function.

• ###### Re: sum added with another sum

Good Morning

I do a grouping as a percent range. Example: expense / Billing is less than 25% then sum amount.

I am unable to use the aggr ().

sum (if (aggr((sum (VALOR_X) / SUM (VALOR_Y)) * 100 <25), QTD)).

• ###### Re: sum added with another sum

Expense / billing per which dimension?

You would need to add these dimension(s) as dimensions to the aggr() function, like

sum( aggr( if( sum(VALOR_X) / sum(VALOR_Y) < 0.25, QTD), Dim1, Dim2, ...))

Replace Dim1, Dim2, ... with the dimensions you need to group by your percentage calculation.

(And either take care that QTD has a single value per these dimensions, or aggregate QTD, too.)