Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Support Case Portal will move to Qlik Community Oct 4. Temporary case outage Oct 3. READ DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
regowins
Creator II
Creator II

Only calculate an accumulation if the above part value is the same

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.

IDPartProcessCumulative
1A11
2A12
3A35
4A27
5B11
6B56
7B28
8B19
9B413

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!

1 Solution

Accepted Solutions
eduardo_sommer
Partner
Partner

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

View solution in original post

6 Replies
Not applicable

Hi Ashwin

do you know you can use "Cumulative option" in some graphs

it might help

Chris

eduardo_sommer
Partner
Partner

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

View solution in original post

Not applicable

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

Not applicable

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.

regowins
Creator II
Creator II
Author

Thanks Guys!  I don't know why I did not think of Peek(). I was over thinking it.

jonathandienst
Partner
Partner

Hi

LOAD

  ID,

  Part,

  Process,

  Process + If(ID = Previous(ID), Peek(Cumulative)) As Cumulative

FROM table

ORDER BY Part, ID;

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein