Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Calculate the days difference between a row and its previous

Hi there,

I have a list of orders, the status they changed into and the date of the stauts change. I want to calculate the days that each order stayed in each status.

In other words the last column in the table below (the one with the red header text).

Is it better to do it in load time or in a straigh table for example using set analysis?

Thank you all in advance.

Order IdDateStatus Description# of Days is Status
115/7/2013Approved1
116/7/2013Awaiting9
125/7/2013Processing0
125/7/2013Finished0
215/7/2013Approved6
221/7/2013Awaiting4
225/7/2013Processing0
225/7/2013Finished0
316/7/2013Approved5
321/7/2013Awaiting4
325/7/2013Processing2
327/7/2013Finished0
410/7/2013Approved0
410/7/2013Awaiting15
425/7/2013Processing1
426/7/2013Finished0
525/6/2013Approved15
510/7/2013Awaiting7
517/7/2013Processing4
521/7/2013Finished0
1 Solution

Accepted Solutions
Gysbert_Wassenaar

See attached example.


talk is cheap, supply exceeds demand

View solution in original post

2 Replies
Gysbert_Wassenaar

See attached example.


talk is cheap, supply exceeds demand
jsakalis
Contributor III
Contributor III

I had a similar use case and found that doing it in the script made sense for me for performance and flexibility reasons.

Performance - I was dealing with about 200 million records, so doing the calculations up front vs. doing calculations on the fly was the better route

Flexibility - Was able to use results in multiple objects in my dashboards without repeating expressions. Also was able to create buckets of days ex. 1-5 days, 6-10, etc.  using Class() . So you can ask the question: How many orders are waiting 6-10 days to be processed.