Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
joboro
Contributor III
Contributor III

Cumulative sum over date ascending but order descending

Hi, I have the following source table:

date quantity
2021-01-01 1
2021-01-02 1
2021-01-03 4
2021-01-04 9

 

I would like to have the following table:

date quantity accum_quantity
2021-01-04 9 15
2021-01-03 4 6
2021-01-02 1 2
2021-01-01 1 1

 

What set analysis should is use for "accum_quantity"? If the output table would be sorted by date ascending i could use the formula: 

Rangesum(ABOVE(Sum(QUANTITY),0,rowno()))

 The best case would be that the sum is independent from the sort order of the table...

KR

Labels (3)
1 Solution

Accepted Solutions
SunilChauhan
Champion II
Champion II

Sorry Mybad use below

RangeSum(Below(Sum(Quantity), 0, NoOfrows(TOTAL)))

Sunil Chauhan
Sunil Chauhan

View solution in original post

11 Replies
SunilChauhan
Champion II
Champion II

try this 
RangeSum(Below(Sum(Quantity), 0, RowNo(TOTAL)))

Sunil Chauhan
joboro
Contributor III
Contributor III
Author

Unfortunately not: 

joboro_1-1716381550203.png

 

 

SunilChauhan
Champion II
Champion II

Sorry Mybad use below

RangeSum(Below(Sum(Quantity), 0, NoOfrows(TOTAL)))

Sunil Chauhan
Sunil Chauhan
joboro
Contributor III
Contributor III
Author

Yes, thats look about right. Thanks!

Do you also know a solution to make it sort order independent? Currently i have to use two different measures depending weather i sort by date descending or ascending.

SunilChauhan
Champion II
Champion II

it would be sort based on only one either ascending or descending.

Sunil Chauhan
joboro
Contributor III
Contributor III
Author

yes, but if the user clicks on the column name and changes the sort order the values don't add up

SunilChauhan
Champion II
Champion II

is it happening to Pivot table also?

Sunil Chauhan
joboro
Contributor III
Contributor III
Author

Yes, as long as the user has the ability to change the sort order, the calculations are off

SunilChauhan
Champion II
Champion II

Not sure on this . you may check this thread 

https://community.qlik.com/t5/App-Development/Qlik-Sense-how-to-disable-sort-feature-on-straight-tab... 

Hope this give some insight.

Sunil Chauhan