Skip to main content
Announcements
Meet the 2024 Qlik Luminaries and Partner Ambassadors! READ ON!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

rangeavg functions ( urgent)

hi

i am not able to understand how the function

rangeavg(above(sum(columnname),1,3)) works...plz explain with an example...it wud help me in understanding other range functions....

6 Replies
swuehl
MVP
MVP

I assume you are using this expression in the context of a (straight) table, like

Dimension     Expression

A                    10

B                    20

C                    30

D                    40

where Expression is e.g. sum(columname).

If you add a second expression

rangeavg(above(sum(columnname),1,3))

the above(sum(columnname),1,3) will not return a single value, but a range of values, in detail the sum(columnname) as evaluated in the 3 rows above the current row (please check the parameter details of above() in Help).

For example, in Line D, above(sum(columnname),1,3) will return the range of values {10,20,30}

If there are not enough lines above (less then three), just the available number of rows will be used.

The enclosing rangeavg() function will then take the range of values and calculate the average (10+20+30)/3=20

Hope this helps,

Stefan

Not applicable
Author

i understan it but i am attaching a snap with it..look itto this case it is not working...

the expression i used here is below.plz explain it to me gor the ist 2 values of salary??untitled.JPG

RangeAvgrangeavg(above(sum(salary),1,3))

swuehl
MVP
MVP

hard to say, I can only see field value salary, but not sum(salary) as expression.

What is your dimension, have you hidden the dimensions?

Not applicable
Author

have a look at it...it will help u in understandingtest2.JPG

swuehl
MVP
MVP

Still I can't see plain sum(salary) as expression. Seems to me that you have two records with salary 17000 (first line), so sum(salary) will return 34000.

fashid
Specialist
Specialist

I have a similar issue with RangeAvg. I am Attaching a qvw file which i have been working on. Could you help me with that what could be wrong ..