Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
HI,
I want to calculate the cumulative of Process if the value in the Part field is same as the above value. If not then use the Process value for the next part to start the accumulation again. Below is an example.
ID | Part | Process | Cumulative |
1 | A | 1 | 1 |
2 | A | 1 | 2 |
3 | A | 3 | 5 |
4 | A | 2 | 7 |
5 | B | 1 | 1 |
6 | B | 5 | 6 |
7 | B | 2 | 8 |
8 | B | 1 | 9 |
9 | B | 4 | 13 |
I would like to do this in the script since I have many types of similar accumulations with a look back to the previous part.
Thanks for the help!
Use this:
LOAD
*,
if (Part = peek(Part), peek(Cumulative)+Process, Process) as Cumulative
INLINE [
ID,Part,Process
1,A,1
2,A,1
3,A,3
4,A,2
5,B,1
6,B,5
7,B,2
8,B,1
9,B,4
];
Eduardo
Hi Ashwin
do you know you can use "Cumulative option" in some graphs
it might help
Chris
Use this:
LOAD
*,
if (Part = peek(Part), peek(Cumulative)+Process, Process) as Cumulative
INLINE [
ID,Part,Process
1,A,1
2,A,1
3,A,3
4,A,2
5,B,1
6,B,5
7,B,2
8,B,1
9,B,4
];
Eduardo
If you want to do it in the script you could use the Peek() function to check if the value of Part is the same as the value of the previously loaded record.
Something along the lines of:
if(Part = Peek(Part), Peek(Cumulative)+Process, Process) as Cumulative
Gio
I tried with some things. In the script you can try FieldValue, Previous and Peek function. But I was not able to get it with the script.
It can give only the sum of 2 rows. To get it for
In the chart you can just do a full accumulation and add Part as a dimension. It will automatically calculate thecummulative sum.
PFA the qvw file.
Thanks Guys! I don't know why I did not think of Peek(). I was over thinking it.
Hi
LOAD
ID,
Part,
Process,
Process + If(ID = Previous(ID), Peek(Cumulative)) As Cumulative
FROM table
ORDER BY Part, ID;
HTH
Jonathan