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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
arethaking
Creator II
Creator II

rangesum (above(count(x),-1,3))

Hi all,

what is the rangesum (above(count(x),-1,3)) meaning?

1 Solution

Accepted Solutions
its_anandrjs
Champion III
Champion III

Dear King,

Let assume this example

Id,Values

A,120

B,100

C,300

D,140

Rangesum( above (count (Values),-1,3 )  )

1. If you count Values with range sum with above function.

2. This expression Count(Values) count the values.

3. Above( Count(Values) ) this means it have to count value above but range is given -1, 3 means it checks value below upto 3 values (Rows).

4. Try to check another expression as range from 1 to 3

Rangesum( above (count (Values),1,3 )  )

You get 0,1,2,3

a. If you see the table for first row that is A there is no row above it.

b. Same for B row we check the rows upto 3 rows so we get only 1 row.

c. Same for C we get 2 row and for D we get 3 rows.

Note:- If you use this expression Rangesum( above (count (Values),-1,3 )  ) then just reverse your out put.

See this results:-

   

Idrangesum (above(count(Values),-1,3))rangesum (above(count(Values),1,3) )
A30
B21
C12
D03

Regards,

Anand

View solution in original post

4 Replies
marcus_sommer

Take a look here: Missing Manual - Above() and Below()

- Marcus

its_anandrjs
Champion III
Champion III

Actually this counts the row below the current row upto three rows rangesum (above(count(x),-1,3))

Ex:-

LOAD * Inline

[

Id,ColA

A,120

B,100

C,300

D,140

];

If you use this expression rangesum (above(count(x),-1,3))

You get result as

A 3

B 2

C 1

1. In c id Row you have only 0ne row that's why 1.

2. Same as for A and B.

Regards

Anand

arethaking
Creator II
Creator II
Author

I am sorry Anand Chouhan, I did not understand.

its_anandrjs
Champion III
Champion III

Dear King,

Let assume this example

Id,Values

A,120

B,100

C,300

D,140

Rangesum( above (count (Values),-1,3 )  )

1. If you count Values with range sum with above function.

2. This expression Count(Values) count the values.

3. Above( Count(Values) ) this means it have to count value above but range is given -1, 3 means it checks value below upto 3 values (Rows).

4. Try to check another expression as range from 1 to 3

Rangesum( above (count (Values),1,3 )  )

You get 0,1,2,3

a. If you see the table for first row that is A there is no row above it.

b. Same for B row we check the rows upto 3 rows so we get only 1 row.

c. Same for C we get 2 row and for D we get 3 rows.

Note:- If you use this expression Rangesum( above (count (Values),-1,3 )  ) then just reverse your out put.

See this results:-

   

Idrangesum (above(count(Values),-1,3))rangesum (above(count(Values),1,3) )
A30
B21
C12
D03

Regards,

Anand