Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
zjalalacssi
Partner - Contributor III
Partner - Contributor III

Get Previous Values

Hi Everyone,

I have the sample data below and i would like to get the Previous Value Column,

For each Quarter, get the value of the previous one, either in the script or in the chartSample Data.PNG

Thank's in Advance

13 Replies
Anonymous
Not applicable

Hi Zineb,

May following code is helpful,

Table:

LOAD * INLINE [

    Quater, Dim1, Dim2, Dim3, Value

    Q1, D1, DD1, D001, 10

    Q1, D1, DD1, D002, 20

    Q2, D1, DD1, D001, 33

    Q2, D1, DD1, D002, 54

    Q3, D1, DD1, D001, 90

    Q3, D1, DD1, D002, 20

    Q4, D1, DD1, D001, 129

    Q4, D1, DD1, D002, 40

];

Load *,

if(IsNull(peek(Value,-2)),0,peek(Value,-2)) as Previous

Resident Table

;

In Front end just take table box,

table.PNG

just go to sort in properties and sort the table as follow

sorting.PNG

zjalalacssi
Partner - Contributor III
Partner - Contributor III
Author

Thank you everyone for your reponses, but all the solutions provided are not working.

I have tried this solution, to get Previous Data in a separate table and join it to my original table using a new generated key and playing with the quarter number.

PREVIOUS_DATA:

Load

'Q'&num(SubField(Quarter,'Q',2)+1) &'-'&DIM1&'-'&DIM2&'-'&DIM3    as Key_quarter,

Sum(PRIMES) as PrevPRIMES

resident MyTable

Group by Quarter,DIM1,DIM2,DIM3;

It worked perfectly.

Thank's Again.

qlikviewwizard
Master II
Master II

Hi zjalalacssi,

Try like this.

Capture.JPG

qlikviewwizard
Master II
Master II

Hi,

Did you try my solution also?

aggr(Above(Sum( PRIMES ) ),DIM1,DIM2,DIM3)