Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
adamjiawen
New Contributor II

sum according to another column


Hello,Everybody,I'm a new fish here,

Latest I got a problem and hopes for everyone's help

In QlikView, I've got a random table like this

--------------------------------------------------------------------

COLUMN1       COLUMN2          COLUMN3

A                     10    

A                     20

A                     30

B                     20

B                     5

B                     25

C                     10

C                     12

C                     22

----------------------------------------------------------------------

Now I want to account for result like this:

----------------------------------------------------------------------

COLUMN1        COLUMN2           COLUMN3

A                     10                       10

A                     20                       30

A                     30                       60

B                     20                       20

B                     5                         25

B                     25                       50

C                     10                       10

C                     12                       22

C                     22                       44

----------------------------------------------------------------------

So how can I do to solve this problem.              

Tags (5)
1 Solution

Accepted Solutions
MVP
MVP

Re: sum according to another column

Create a straight table

Dimension =

Column1

Column2

Expression

RangeSum(Above(SUM(COLUMN2),0,RowNo()))

UPDATE : You can do the same at script level

Temp:

Load * Inline

[

  COLUMN1, COLUMN2        

  A,       10  

  A,          20

  A,          30

  B,          20

  B,           5

  B,          25

  C,          10

  C,          12

  C,          22

];

NoConcatenate

Final:

Load

  COLUMN1,

  COLUMN2,

  IF(COLUMN1 = PEEK('COLUMN1'), RangeSum(Peek('COLUMN3'),COLUMN2), COLUMN2) as COLUMN3

Resident Temp

Order By COLUMN1;

Drop Table Temp;

3 Replies
MVP
MVP

Re: sum according to another column

Create a straight table

Dimension =

Column1

Column2

Expression

RangeSum(Above(SUM(COLUMN2),0,RowNo()))

UPDATE : You can do the same at script level

Temp:

Load * Inline

[

  COLUMN1, COLUMN2        

  A,       10  

  A,          20

  A,          30

  B,          20

  B,           5

  B,          25

  C,          10

  C,          12

  C,          22

];

NoConcatenate

Final:

Load

  COLUMN1,

  COLUMN2,

  IF(COLUMN1 = PEEK('COLUMN1'), RangeSum(Peek('COLUMN3'),COLUMN2), COLUMN2) as COLUMN3

Resident Temp

Order By COLUMN1;

Drop Table Temp;

adamjiawen
New Contributor II

Re: sum according to another column

Can you please write the script in details?Best write a part of critical scripts thanks

adamjiawen
New Contributor II

Re: sum according to another column

Thank you very much for your help~

Community Browser