Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
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

1 Solution

Accepted Solutions
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.

View solution in original post

13 Replies
vishsaggi
Champion III
Champion III

Try this in your Straight table expr

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

eduardo_dimperio
Specialist II
Specialist II

SCRIPT:

LOAD

VALUE

PEEK(VALUES) AS PREVIOS VALUE

RESIDENT YOURTABLE

ORDER BY

ASC VALUE;

zjalalacssi
Partner - Contributor III
Partner - Contributor III
Author

Hello,

Thank you for your reply

This is the result i get when applying your formula.Result.PNG

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

Thank you very much

vishsaggi
Champion III
Champion III

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

zjalalacssi
Partner - Contributor III
Partner - Contributor III
Author

Actually the Expected Result is:

 

QuarterDIM1DIM2DIM3PRIMESPrev
Q1D1DD1DD110
Q2D1DD1DD22010
Q3D1DD1DD33020
Q4D1DD1DD46030
Q1D2DD2DD5100
Q2D2DD2DD6200100
Q3D2DD2DD7300200
Q4D2DD2DD8400300

Thank you

Anil_Babu_Samineni

Can you do this?

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

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anonymous
Not applicable

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

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

qv.JPG

jonathandienst
Partner - Champion III
Partner - Champion III

How about this:

LOAD Quarter,

     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
Anonymous
Not applicable

qv.JPG

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