Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead 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

Can you guys please help me to understand the reasons?

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Maybe like

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

View solution in original post

9 Replies
swuehl
MVP
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().

And start with

Dimensions and Measures

It’s all Aggregations

Pitfalls of the Aggr function

sasikanth
Master
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:

jonathandienst
Partner - Champion III
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

swuehl
MVP
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 🙂