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

Smaller or equal too calculating with times

Hi,

I'm trying to report how many trucks in my dataset arrived on time. All trucks that arrive within half an hour after their booked time (Delivery Due Time), or on time. To do this, I added the following line to my script:


If([Vehicle arrival Time]-[Delivery DueTime]<=(1/48), 1,0) as [On time]

If a truck is half an hour late (1/48 hour), it is still on time. That's why i put <= 1/48 in my script. However, when the truck arrives exactly half an hour later than their booked time, Qlikview still regards them as late (it gives them a "0" as value). Can anybody explain this/help me with this issue?

Thanks

1 Solution

Accepted Solutions
Not applicable
Author

Hi

I tried the suggestions with the Round(..) formula, but it didn't work either. Eventually, I changed 1/48 to 31/1440. That solved the problem.

Thanks for your help

Best regards,

Niek

View solution in original post

5 Replies
Clever_Anjos
Employee
Employee

Maybe some rounding problem, try rounding to nearest minute

If(round([Vehicle arrival Time]-[Delivery DueTime],1/(24*60))<=(1/48), 1,0) as [On time]

nilesh_gangurde
Partner - Specialist
Partner - Specialist

Please attach sample qvw.

-Nilesh

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

I would try and take the floating point comparison out completely, like this

     If(Round(([Vehicle arrival Time]-[Delivery DueTime]) * 48) <= 1, ...)

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
jonathandienst
Partner - Champion III
Partner - Champion III

Or

      If(Round(([Vehicle arrival Time]-[Delivery DueTime]) * 24, 0.1) <= 0.5, ...)

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Hi

I tried the suggestions with the Round(..) formula, but it didn't work either. Eventually, I changed 1/48 to 31/1440. That solved the problem.

Thanks for your help

Best regards,

Niek