Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
adamjiawen
Contributor II
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.              

1 Solution

Accepted Solutions
MK_QSL
MVP
MVP

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;

View solution in original post

3 Replies
MK_QSL
MVP
MVP

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
Contributor II
Contributor II
Author

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

adamjiawen
Contributor II
Contributor II
Author

Thank you very much for your help~