Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Help on Peek Function to read next record an add value to present record

Hello

I am trying to solve the chapter 12 Use case in Qlikview 11 for developers - What happens if all we have is a start date

Trying to achieve this-  "peek" at the start value from the next record, subtract one day and that will be our new end date by

loading  from QVD with out the End date and adding the end date by ordering and peeking - but getting the end date  as spaces..

[Initial Load]:

LOAD [%Airline ID],

     [Carrier Code],

     [Carrier Entity],

     [Carrier Name],

     [Unique Carrier Code],

     [Unique Carrier Entity],

     [Unique Carrier Name],

     [Carrier World Area Code],

     [Carrier Group ID (Old)],

     [Carrier Group ID],

     [Region Code],

     [Start Date]

     //[End Date]

FROM

[..\3.QVD\Source\Carrier Decode.qvd]

(qvd);

Temp_Carrier_decode:

LOAD

     [%Airline ID],

     [Carrier Code],

     [Carrier Entity],

     [Carrier Name],

     [Unique Carrier Code],

     [Unique Carrier Entity],

     [Unique Carrier Name],

     [Carrier World Area Code],

     [Carrier Group ID (Old)],

     [Carrier Group ID],

     [Region Code],

     [Start Date],

     if(

     [Unique Carrier Entity] = Peek('Unique Carrier Entity',RowNo()+1,'Temp_Carrier_decode'), Date(Peek('Start Date',RowNo()+1,'Temp_Carrier_decode')-1), ' '

     ) as [End Date]

Resident [Initial Load]

Order By [Unique Carrier Code],[Start Date] desc;

Drop Table [Initial Load];

1 Solution

Accepted Solutions
maxgro
MVP
MVP

maybe

if([Unique Carrier Entity] = Peek('Unique Carrier Entity'), Date(Peek('Start Date') -1), '') as [End Date]

View solution in original post

5 Replies
sunny_talwar

May be try this:

If([Unique Carrier Entity] = Peek('Unique Carrier Entity'), Date(Peek('Start Date') - 1), ' ') as [End Date]

maxgro
MVP
MVP

maybe

if([Unique Carrier Entity] = Peek('Unique Carrier Entity'), Date(Peek('Start Date') -1), '') as [End Date]

Not applicable
Author

Thank you  Sunny,Maxgro, this works if we order in descending order  and peeking previous, any means to peek  next record  ( by keeping the sort in ascending).

sunny_talwar

I don't think this can work without changing the sort order.Why are you reluctant to change the sort order to descending? It won't have any change on the front end except for anywhere you use Aggr function.

Not applicable
Author

Thank you Sunny, just wanted to know if it was feasible. this helps