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

previous day price

Hi experts,

I have a small requirement, where I have to show current price and previous day price on same row,I Cant use Date-1 to get previous day price, because I won't be having weekend data.

Please see example below

   

ProdIdDatePrice
A1236/15/2015100
A1236/12/201599
A1236/11/2015101
A1236/10/2015102
A4566/15/2015105
A4566/12/2015104
A4566/11/2015103
A4566/10/2015100

o/p table should be

   

ProdIdCurrent PricePrevious Price
A123100105
A456105104

Table should be dynamic based on date selection. Please help

7 Replies
ramoncova06
Partner - Specialist III
Partner - Specialist III

you can use peek for this

Price:

load * Inline

[ProdId Date Price

A123 6/15/2015 100

A123 6/12/2015 99

A123 6/11/2015 101

A123 6/10/2015 102

A456 6/15/2015 105

A456 6/12/2015 104

A456 6/11/2015 103

A456 6/10/2015 100]

(delimiter is ' ')

;

load

if(Peek(ProdId) = ProdId, Peek(Price)) as [Previous Price],

*

Resident Price

order by ProdId, Date;

drop table Price;

maxgro
MVP
MVP

maybe

FirstSortedValue(Price, -Date, 2)

FirstSortedValue(Price, -Date)

Not applicable
Author

Hi Ramon,

Can you let me know if you can do by set analysis, I can't use peek function, because I have to show lot of other columns in table. Please let me know.

Not applicable
Author

doen't work gives null value

sinanozdemir
Specialist III
Specialist III

When I tried Massimo's suggestion, I didn't get any NULL values:

Capture.PNG

Not applicable
Author

i have lot of other dimensions in table..may be thats why its not working

maxgro
MVP
MVP

maybe is better you post some data with 2 (or more) dimensions

we're answering to a question but the real one is different