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: 
AirtonSantos97
Contributor
Contributor

Accumulation of value

Hi, 

I am newbie in Qlik. I need to have an accumulated value as my example below:

Defect Number of occurrences Accumulation
A 10 10
B 4 14
C 7 21
D 20 41
E 16 57
F 9 66

 

I have a table with Defect and Number of ocurrences and I need anothe column with  Accumulation.

How can I do it?

Thank you all in advance.

 

Labels (1)
1 Solution

Accepted Solutions
BrunPierre
Partner - Master
Partner - Master

Hi, as below.

Tmp:
LOAD Defect,
[Number of occurrences],
RecNo() as Rec#
FROM YourTable;

NoConcatenate
Data:
LOAD Defect,
[Number of occurrences],
If(Rec# = 1, [Number of occurrences], [Number of occurrences] + Peek('Accumulation')) as Accumulation

Resident Tmp;

DROP Table Tmp;

View solution in original post

2 Replies
BrunPierre
Partner - Master
Partner - Master

Hi, as below.

Tmp:
LOAD Defect,
[Number of occurrences],
RecNo() as Rec#
FROM YourTable;

NoConcatenate
Data:
LOAD Defect,
[Number of occurrences],
If(Rec# = 1, [Number of occurrences], [Number of occurrences] + Peek('Accumulation')) as Accumulation

Resident Tmp;

DROP Table Tmp;

AirtonSantos97
Contributor
Contributor
Author

BrunPierre,

Thank you very much. It worked very well ! 

Certainly, my code is not the best, because I am a beginner, but it gave me what I needed.
Thank you again.
Airton

Here is my code:

TMP:
LOAD CODFALHA,
QTDFALHAS,
RecNo() as Rec#
Resident PARETO;

NoConcatenate
ACUMPARETO:
LOAD CODFALHA,
QTDFALHAS,
If(Rec# = 1, QTDFALHAS, QTDFALHAS + Peek('ACCUMULATION')) as ACCUMULATION
Resident TMP;

STORE ACUMPARETO into ..\Dados\Acumpareto.qvd(qvd);

PARETODEF:
LOAD CODFALHA,
QTDFALHAS as QTDFAILURES
Resident TMP;

LEFT JOIN (PARETODEF)
LOAD CODFALHA,
QTDFALHAS,
ACCUMULATION as ACUMULADO
FROM
[..\Dados\Acumpareto.qvd]
(qvd);
drop Field QTDFAILURES From PARETODEF;

DROP TABLE TMP;
DROP TABLE ACUMPARETO;
DROP TABLE PARETO;