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: 
17George
Contributor II
Contributor II

Average with negative values

Hello,
On the left side the scores with some negative values and on the right side
the modified results if I use fabs( sum(score)/count(name)) or RangeAvg(fabs(score)).

How can I keep the scores unchanged and also show the average value of them in my expression?

avg.jpg

Labels (3)
1 Solution

Accepted Solutions
marcus_sommer

You don't mentioned the place and context in which the values/results should be displayed. Therefore various approaches are thinkable, for example:

  • adding an extra field with positive/negative information
  • using dual() values, like: dual(value, fabs(value))
  • querying the dimensionality in a pivot, like if(dimensionality() = 0, fabs(value), value)

- Marcus

View solution in original post

4 Replies
marcus_sommer

You don't mentioned the place and context in which the values/results should be displayed. Therefore various approaches are thinkable, for example:

  • adding an extra field with positive/negative information
  • using dual() values, like: dual(value, fabs(value))
  • querying the dimensionality in a pivot, like if(dimensionality() = 0, fabs(value), value)

- Marcus

PrashantSangle

Use fabs() inside sum()

 sum(fabs(score))/count(name)

Regards,

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
17George
Contributor II
Contributor II
Author

Thanks @marcus,
both suggestions, dual( ) & dimensionality() worked as desired in my table.

Is there a possibility to adjust the  results according to the weighted factor of +/- signs?
For example: avg (-3, -7) = 5 and sum(-3,-7) = -10. 
Since the negative sign is overweighing,  -5  might be adopted  as "adjusted" average.


marcus_sommer

I'm not sure what you mean with an adjusted average but both in the origin question mentioned methods may be adaptable for it - means: sum() / count() and/or rangeavg() - directly or combined with an aggr(), maybe like:

avg(aggr(sum() / count() , Dim1, Dim2))

or

rangeavg(aggr(only(Value), Value))

- Marcus