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

Calculated duration in minutes, less than or equal to specified value

I am trying to determine when a calculated duration is less than or equal to 30 minutes as a measure.

I tried using the following:

Count({$<(InRoomTm-ArrWaitTm)*1440)={"<=$(=30)"}>}(InRoomTm-ArrWaitTm)*1440))

but there is an error, with no output

&

Count(if(((PtInRoomTm-PtArrWaitTm)*1440) <=30, 1)) / count(all ((PtInRoomTm-PtArrWaitTm)*1440))

but the output is incorrect

Does anyone have a solution/fix to this?

9 Replies
sunny_talwar

Do you want to do a count here or Sum?? May be try something like this

Sum({$<UniqueIdentifierField = {"=(InRoomTm-ArrWaitTm)*1440) <= 30"}>} (InRoomTm-ArrWaitTm)*1440)

Not applicable
Author

Thank you @Sunny T! I believe its closer, but I'm still not getting the correct output.

I've put in:

Sum({$<VisitNum = {"=(InRoomTm-ArrWaitTm)*1440) <= 30"}>} ((InRoomTm-ArrWaitTm)*1440))

But I'm getting an error message of "Bad field name: InRoomTm, ArrWaitTm" for the second instance of "...(InRoomTm-ArrWaitTm)*1440) "

Any thoughts? Not sure why it's not reading it since the expression is correctly formatted.

sunny_talwar

Seems like we left one extra parenthesis in the expression:

Sum({$<VisitNum = {"=(InRoomTm-ArrWaitTm)*1440) <= 30"}>} ((InRoomTm-ArrWaitTm)*1440))

Try this:

Sum({$<VisitNum = {"=(InRoomTm-ArrWaitTm)*1440 <= 30"}>} ((InRoomTm-ArrWaitTm)*1440))

Not applicable
Author

It's still not reading that second instance of the calculation:

Qlik_expressionER_2017-02-09.png

sunny_talwar

What exactly is InRoomTm and ArrWaitTm? Are these field names or are they variables

Not applicable
Author

They are field names populated with times.

sunny_talwar

Would you be able to share a sample to take a look at the issue?

Not applicable
Author

Let me know if this helps:

   

VisitNumSchedDTArrWaitTmInRoomTm
11/1/20177:227:30
22/1/20178:098:15
312/1/20168:068:50

I want to know both the count of how many visits had a wait time of 30 mins or less from arrival time (ArrWaitTm) to time seen (InRoomTm) & what that count is as a percentage of total number of visits.

sunny_talwar

Two methods

1)

=Sum({<Flag = {1}>}(InRoomTm - ArrWaitTm) * 1440)

2)

Sum({<VisitNum = {"=InRoomTm-ArrWaitTm <= MakeTime(0, 30)"}>}(InRoomTm - ArrWaitTm) * 1440)

For method one, I have created a flag in the script:

Table:

LOAD *,

  If(InRoomTm - ArrWaitTm <= MakeTime(0, 30), 1, 0) as Flag;

LOAD * INLINE [

VisitNum, SchedDT, ArrWaitTm, InRoomTm

1, 1/1/2017, 7:22, 7:30

2, 2/1/2017, 8:09, 8:15

3, 12/1/2016, 8:06, 8:50

];

Capture.PNG