# New to QlikView

Discussion board where members can get started with QlikView.

Highlighted
Partner

## 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 chart

Tags (2)
1 Solution

Accepted Solutions
Partner

## Re: Get Previous Values

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:

'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.

13 Replies
Esteemed Contributor III

## Re: Get Previous Values

Try this in your Straight table expr

= IF(RowNo(TOTAL) = 1 OR RowNo(TOTAL) =2, 0, Above(TOTAL Sum(Value),2))

Valued Contributor II

## Re: Get Previous Values

SCRIPT:

VALUE

PEEK(VALUES) AS PREVIOS VALUE

RESIDENT YOURTABLE

ORDER BY

ASC VALUE;

Partner

## Re: Get Previous Values

Hello,

This is the result i get when applying your formula.

Note please that in my final Table i won't need the Quarter anymore.

Thank you very much

Esteemed Contributor III

## Re: Get Previous Values

Ok, is that not your expected output? if not what should be your expected output please let us know.

Partner

## Re: Get Previous Values

Actually the Expected Result is:

 Quarter DIM1 DIM2 DIM3 PRIMES Prev Q1 D1 DD1 DD1 10 Q2 D1 DD1 DD2 20 10 Q3 D1 DD1 DD3 30 20 Q4 D1 DD1 DD4 60 30 Q1 D2 DD2 DD5 100 Q2 D2 DD2 DD6 200 100 Q3 D2 DD2 DD7 300 200 Q4 D2 DD2 DD8 400 300

Thank you

## Re: Get Previous Values

Can you do this?

Aggr(Above(Sum(PRIMES)), DIM1)

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
Contributor

## Re: Get Previous Values

try this on your Previous Field expression in straight table..

aggr(above( aggr(PRIMES,DIM1,Quarter)),DIM1,Quarter)

MVP

## Re: Get Previous Values

DIM1,

DIM2,

DIM3,

PRIMES,

If(AutoNumberHash256(DIM1, DIM2, DIM3)

= Previous(AutoNumberHash256(DIM1, DIM2, DIM3)),

Previous(PRIMES)

) as Prev

FROM  ....

ORDER BY DIM1, DIM2, DIM3, Quarter

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

## Re: Get Previous Values

aggr(above( aggr(PRIMES,DIM1,Quarter)),DIM1,Quarter)