Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
reivax31
Partner - Creator III
Partner - Creator III

RangeSum in script

Hi Qlikers,

I'm trying to find a way to operate a rangesum within the script. Table looks like this:

ITEMOCCURRENCECUMUL
A11
A12
A13
A14
B11
B12
A15
A16
B13
A17
B14
B15
B16



Expected result is in column CUMUL.

Thanks for your help

1 Solution

Accepted Solutions
petter
Partner - Champion III
Partner - Champion III

This is a way to do it:

Merknad 2019-07-15 125756.png

 

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;

 

 

View solution in original post

3 Replies
petter
Partner - Champion III
Partner - Champion III

This is a way to do it:

Merknad 2019-07-15 125756.png

 

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;

 

 

reivax31
Partner - Creator III
Partner - Creator III
Author

YES PERFECT !

petter
Partner - Champion III
Partner - Champion III

Please click "like" to give credit as that is the only way that actual credit is given on this forum ... strangely enough ... 🙂