Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Announcing the newest addition to the Qlik Community, Qlik Gallery! Learn More
Partner
Partner

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
MVP
MVP

Re: RangeSum in script

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;

 

 

3 Replies
MVP
MVP

Re: RangeSum in script

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;

 

 

Partner
Partner

Re: RangeSum in script

YES PERFECT !

MVP
MVP

Re: RangeSum in script

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