Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
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;
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;
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;