Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Dear Experts,
I need to figure out how to do a rolling sum in the Qlik sense.
I have the data as shown below
Current table | ||
id | date | value |
1 | Jan | 10 |
1 | Feb | 20 |
1 | March | 30 |
1 | April | 40 |
1 | May | 50 |
2 | Feb | 10 |
2 | March | 20 |
2 | May | 30 |
2 | June | 40 |
Need the data as below
Required Table | |||
id | date | value | Cummulative |
1 | Jan | 10 | 10 |
1 | Feb | 20 | 30 |
1 | March | 30 | 60 |
1 | April | 40 | 100 |
1 | May | 50 | 150 |
2 | Feb | 10 | 10 |
2 | March | 20 | 30 |
2 | May | 30 | 60 |
2 | June | 40 | 100 |
Thanks for your time
create table in QS
Add ID & Date as dimension
Add Only(Value) and Alt(Above(Only(value)),0)+Only(value) as Measure
Use this as second expression instead
Alt(if(IsNull(Above(Cumulative))=-1,Above(Only(value)), Above(Column(2))),0)+Only(value)
Have you tried
RangeSum(Above(Sum(value), 0, RowNo()))
This works only when my table is sorted by date, but if i sort by Id. The value changes as RowNO() value get updated based on the sort.
Try this
Aggr(RangeSum(Above(Sum(value), 0, RowNo())), id, (date, (NUMERIC)))