Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

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?

5 Replies
swuehl
MVP
MVP

Just need to add a closing bracket at the end:

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

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

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

-Rob

swuehl
MVP
MVP

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.

Not applicable
Author

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)).

swuehl
MVP
MVP

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.)