
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
RangeSum in script
Hi Qlikers,
I'm trying to find a way to operate a rangesum within the script. Table looks like this:
ITEM | OCCURRENCE | CUMUL |
A | 1 | 1 |
A | 1 | 2 |
A | 1 | 3 |
A | 1 | 4 |
B | 1 | 1 |
B | 1 | 2 |
A | 1 | 5 |
A | 1 | 6 |
B | 1 | 3 |
A | 1 | 7 |
B | 1 | 4 |
B | 1 | 5 |
B | 1 | 6 |
Expected result is in column CUMUL.
Thanks for your help
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is a way to do it:
RAW_DATA:
LOAD
RowNo() AS R#,
*
INLINE [
ITEM OCCURRENCE
A 1
A 1
A 1
A 1
B 1
B 1
A 1
A 1
B 1
A 1
B 1
B 1
B 1
] (delimiter is \t);
DATA:
LOAD
If(R#=1,OCCURRENCE,If(Peek('ITEM')<>ITEM,OCCURRENCE,OCCURRENCE+ Peek('CUMUL'))) AS CUMUL,
*
RESIDENT
RAW_DATA
ORDER BY
ITEM, R#;
DROP TABLE
RAW_DATA;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is a way to do it:
RAW_DATA:
LOAD
RowNo() AS R#,
*
INLINE [
ITEM OCCURRENCE
A 1
A 1
A 1
A 1
B 1
B 1
A 1
A 1
B 1
A 1
B 1
B 1
B 1
] (delimiter is \t);
DATA:
LOAD
If(R#=1,OCCURRENCE,If(Peek('ITEM')<>ITEM,OCCURRENCE,OCCURRENCE+ Peek('CUMUL'))) AS CUMUL,
*
RESIDENT
RAW_DATA
ORDER BY
ITEM, R#;
DROP TABLE
RAW_DATA;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
YES PERFECT !

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please click "like" to give credit as that is the only way that actual credit is given on this forum ... strangely enough ... 🙂
