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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Dynamic Aggregation

Hey guys:

based on user input I want to compute an average over a specific field:

Set vMenu = GetFieldSelections([Menu Item]); (will return Sales or Revenue or Profit..... and so on)

expression: =avg($(vMenu))

For some reason this does not work, even while $(vMenu) will return Sales

and avg(Sales) will also return a valid number.

Any ideas what might be happening?

1 Solution

Accepted Solutions
tresesco
MVP
MVP

Put '=' in variable definition. See attached.

View solution in original post

9 Replies
MK_QSL
MVP
MVP

Try

expression: =avg($(=vMenu))

Not applicable
Author

Nope, unfortunately

tresesco
MVP
MVP

Could you post your sample app with the issue?

Not applicable
Author

Yes, here is a demo app with public data.

tresesco
MVP
MVP

Put '=' in variable definition. See attached.

Not applicable
Author

Try =avg($(=$(vMenu)))

Not applicable
Author



Try =avg($(=$(vMenu)))

I tested with selecting Sloop. it works. for other fields Menu list does not have corresponding same name in the fields..

Not applicable
Author

Thanks, I had tried with '=', but I must have made some typo. Anyway, now it works:

set vMenu = ='[' & GetFieldSelections([Menu Item]) & ']';

tresesco
MVP
MVP

Yes, that would be required for values with spaces in between.