Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
rsaeedga
Contributor II
Contributor II

Difference Between 2 Consecutive Delivery Dates

I have a requirement as Below:

We have Products that can have a future Delivery Date. I need to calculate the Gap between the 2 consecutive Delivery Dates for EA Product.   I will need to create 3 new columns as Start Gap, End Gap and the difference of the 2.  

So for the first delivery Date of the Product 'A', Start Gap will be Todays Date and End Gap will be the first Delivery Date,

For the second Delivery Date the Previous End Gap will be the Start Gap as shown in the example below. The bold columns is the expected output

Product Delivery Date Start Gap End Gap Gap Months
A 12/1/2022 Today 12/1/2022 60
A 12/1/2023 12/1/2022 12/1/2023 365

 

How can I create the Columns (Start Gap, End Gap) in the script. Please keep in mind Delivery Dates have to be grouped by the Product.

Attached is the sample file with 2 Products. 

 

 

 

 

Labels (2)
4 Replies
oskartoivonen
Partner - Contributor III
Partner - Contributor III

This can be handled with a pretty standard Peek-function usage. Prepare your data, order by delivery date, and start peaking the previous row. You start by finding the starting row for each product, the peek will either return null or a different product, and set start gap to Today(). For each following row, compare product to ensure the product chain and peek previous row end gap into start gap field. End gap field you can just set to delivery date, it's always the same. Add a preceding load to compare start and end gap for your gap months field.

rsaeedga
Contributor II
Contributor II
Author

Can u psl provide a sample QVF using my sample Data

MarcoWedel

can u pls provide a sample QVF that demonstrates how far your own efforts took you and describe which of the three derived fields you had difficulties with?