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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Variable Value

I have written this formula to calculate mean value of a product in all the territories and stored it in a variable. But whenever i am selecting any territory that variable value is changing. But it should remain same irrespective of whatever selection i make. what could be the reason for the difference in value.
=
avg(aggr(
num(
((
sum({$<%EPID={1},Segment={'Stucks'}, TERRITORY=>} (Volume))/sum({$<%EPID={7},Segment={'Stucks'},TERRITORY=>} (Volume)))-
((
sum({$<%EPID={1},Segment={'Stucks'},TERRITORY=>} (Volume))-sum({$<%EPID={1},Segment={'Stucks'},TERRITORY=>} (Volume_Change))))/
((
sum({$<%EPID={7},Segment={'Stucks'},TERRITORY=>} (Volume))-sum({$<%EPID={7},Segment={'Stucks'},TERRITORY=>} (Volume_Change)))))

,'#,##0.0%'),
TERRITORY))
to make the variable value constant we can load this formula in the load script. But i dont know how to do that. Please Help
1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Hard to say without an example to test, but I suspect the problem is that there is no set expression on the avg() function itself, so the territory selection will affect the avg. Try

=avg({<TERRITORY=>} aggr(..))

Incidentally, the Num inside the aggr is doing nothing except making the statement more complex. If you want to format the results, the num should be the topmost expression.

=num(avg({<TERRITORY=>} aggr(..)), '0%')

Hope that helps

Jonathan

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

View solution in original post

2 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Hard to say without an example to test, but I suspect the problem is that there is no set expression on the avg() function itself, so the territory selection will affect the avg. Try

=avg({<TERRITORY=>} aggr(..))

Incidentally, the Num inside the aggr is doing nothing except making the statement more complex. If you want to format the results, the num should be the topmost expression.

=num(avg({<TERRITORY=>} aggr(..)), '0%')

Hope that helps

Jonathan

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

Thanks Jonathan