# QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Action-Packed Learning Awaits! QlikWorld 2023. April 17 - 20 in Las Vegas: REGISTER NOW
cancel
Showing results for
Did you mean:
Not applicable

## Error in expression nested aggregation not allowed

Hi,

I am getting the error "nested aggregation not allowed" for the following Expression:

=sum(\$(dvQuantity_Pref)*Sum({\$<H_ComponentPath={"\$(dvItem)*"}>} TotalDemand)) *sum( Only({\$<H_ComponentPath={"\$(dvItem)*"}>} T\$AMNT_SITM))

dvQuantity_Pref = Qtty - 1

dvItem =  Item No -  xx12542254

(dvItem)* =      xx12542254 /1 and xx12542254/2 and............

TotalDemand = 1

T\$AMNT_SITM= 4,5

1 Solution

Accepted Solutions
MVP

Maybe like

=Sum(Aggr((\$(dvQuantity_Pref)) * Sum({\$<H_ComponentPath={"\$(dvItem)*"}>} TotalDemand) * only({\$<H_ComponentPath={"\$(dvItem)*"}>} T\$AMNT_SITM),H_ComponentPath))

9 Replies
MVP

You can't just embed a Sum() into another Sum().

You could consider using advanced aggregation (Aggr() function), or maybe just include \$(dvQuantity_Pref)

into one of the inner Sum() functions.

To help you more, we need to know the context of this expression.

edit: Same problem with embedding Only() into Sum().

Dimensions and Measures

It’s all Aggregations

Pitfalls of the Aggr function

Master

hi,

Try this,

=sum(\$(dvQuantity_Pref)* (Sum({\$<H_ComponentPath={"\$(dvItem)*"}>} TotalDemand)) )*

(sum({\$<H_ComponentPath={"\$(dvItem)*"}>} T\$AMNT_SITM))

Not applicable
Author

thanks...

But the same error message:

Partner - Champion III

As the inner aggregation terms return only a single value, so you do not need the two outer sums. Try this expression:

=(\$(dvQuantity_Pref)) * Sum({\$<H_ComponentPath={"\$(dvItem)*"}>} TotalDemand) * Only({\$<H_ComponentPath={"\$(dvItem)*"}>} T\$AMNT_SITM)

If that does not work, you may need to use an Aggr() function, but its hard to day without more information about the context iin which this expressions is being used; and your data model.

A sample qvw with some representative data would help, together with a description of what you are trying to achieve, and with expected results.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

This is working :

=Sum({\$<H_ComponentPath={"\$(dvItem)*"}>} TotalDemand)*sum(\$(dvQuantity_Pref))*

sum({\$<H_ComponentPath={"\$(dvItem)*"}>} T\$AMNT_SITM)

But the result is incorrect - The Result is over all items

I Need the Result only for

dvItem = Item No ( for example xx12542254 and xx12542254 *  .....)

Thank

Not applicable
Author

Thanks

But the Result ist   '  -  '

I will create a sample qvw with some representative data.........

Not applicable
Author

Attached the sample qvw with some data

MVP

Maybe like

=Sum(Aggr((\$(dvQuantity_Pref)) * Sum({\$<H_ComponentPath={"\$(dvItem)*"}>} TotalDemand) * only({\$<H_ComponentPath={"\$(dvItem)*"}>} T\$AMNT_SITM),H_ComponentPath))

Not applicable
Author

Many thx 🙂

Community Browser