Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set and sum, nested aggregation not allowed

Hi I want to divide two formulas in one expression, seperately they work fine:

1. =Sum({<field1={'1'}>} field2)

2. =Sum({<field1={'1'}>} field2) - Sum({<field1={'1'}, field3={'-1'}>} field2)

But If try a version with (2.)/(1.) it does not work. If I try that i get 'nested aggregation not allowed' if I add serveral sum functions. Further more I tried to put them in two variables and then divide the variables, but then I get a wrong number. Do I need if and aggr instead?

1 Solution

Accepted Solutions
maleksafa
Specialist
Specialist

try adding parentheses before each formula so that it will be

( Sum({<field1={'1'}>} field2) - Sum({<field1={'1'}, field3={'-1'}>} field2) )

/

(Sum({<field1={'1'}>} field2))

also what is the chart type that you are using?

View solution in original post

4 Replies
maleksafa
Specialist
Specialist

try adding parentheses before each formula so that it will be

( Sum({<field1={'1'}>} field2) - Sum({<field1={'1'}, field3={'-1'}>} field2) )

/

(Sum({<field1={'1'}>} field2))

also what is the chart type that you are using?

alexandros17
Partner - Champion III
Partner - Champion III

what is the mistake it returns when you do

(Sum({<field1={'1'}>} field2) - Sum({<field1={'1'}, field3={'-1'}>} field2))

/

(Sum({<field1={'1'}>} field2))

let me know

Not applicable
Author

Thank you, so I just needed the parentheses at start, I was trying sum(sum(

BTW I seems like that I only need the extra parentheses in the long formula, because I substract two sum's and must capture that.   

Not applicable
Author

Well Malek was first but thank you.