Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to calculate a period of time between two dates

Hi everyone!

I didn't found a solution of my problem in the forums, so, I tried to post this issue here:

I need to calculate the time between n dates in rows (TimeLapsed column). I make this example in excel, but i need to resolve it in Qlikview to obtain aggr data by Area.

Example:

AreaWorkflowChangeDateStatusTimeLapsed
MKT - Especialidades06/05/2010 12:42StartedNULL
MKT - Especialidades06/05/2010 12:43Area Revision0,00
Impuestos21/06/2010 22:37Legal Revision46,41
Asuntos Corporativos y Legales19/07/2010 10:22Aproved to Sign27,49
MKT - Especialidades19/07/2010 10:23Sign off0,00
MKT - Especialidades19/07/2010 10:23Aproved0,00
Asuntos Corporativos y Legales19/07/2010 16:39Finish0,26


Thanks in advance,

Sebastián.

1 Solution

Accepted Solutions
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

I'd recommend calculating Time Lapsed in the load script and not in the chart expression. You need to use functions peek() and previous() to calculate the "current" and the "previous" values of the timestamp.

View solution in original post

7 Replies
Miguel_Angel_Baeyens

Hi Sebastian,

You may use inter record functions:

ChangeDate - Above(ChangeDate)


Is that what you mean?

Not applicable
Author

Yes, but I need to use an aggregation function if I'll use ChangeDate-Above(ChangeDate) this formula as expression return - (error).

Is correct in the theorical way, but Qlikview respond in negative form.


Thanks in advance,

Sebastián.

Miguel_Angel_Baeyens

Hello Sebastián,

This probably has to do with your date formatting. Something like (untested)

Interval(Date(ChangeDate) - Date(Above(ChangeDate)))


might work. If it doesn't create a new column just with

Above(ChagneDate)
just to check which value is your chart taking.

Hope that helps.

Not applicable
Author

Hi Miguel,


Thanks for your answer but when i try to use Above function, it returns - because the parameter must be an aggregation function.

Regards,

Sebastián.

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

I'd recommend calculating Time Lapsed in the load script and not in the chart expression. You need to use functions peek() and previous() to calculate the "current" and the "previous" values of the timestamp.

johnw
Champion III
Champion III

I agree with Oleg's recommendation. Something like this:

LOAD
SomeID
,AreaWorkflow
,Status
,ChangeDate
,if(SomeID=previous(SomeID),interval(ChangeDate-previous(ChangeDate))) as TimeLapsed
...

Not applicable
Author

John / Oleg,

Thanks in advance for your answer. It works ok and it improves the calculating time in the user document.

Good Weekend,

Sebastián.