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

expression less then predefined time

hi,

I have 2 times a start time and an end time of an event. I want to build a gauge chart showing what percentage of the events takes no more then 10 minutes. For this i need an expression that counts all the events with "endtime-starttime<time(0:10)"

i have:

Count ({$<time(EndTime-StartTime) = {"<=$(=time(0:10))"}>} EventId)

Thanks for all the help!

1 Solution

Accepted Solutions
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Can you add the difference between EndTime and StartTime as a column to your Events table? Its value should equal the expression your already applied, e.g. minute(EndTime-StartTime) AS DurationMinutes

Then your gauge expression becomes:

= count ({<DurationMinutes = {"<=10"}>} EventId)/count(EventId)

or if you want to make the minimum duration fexible, you can add a slider to set a variable called vMinDur, and your expression becomes:

= count({<DurationMinutes = {"<=$(vMinDur)"}>} EventId)/count(EventId)

View solution in original post

12 Replies
Not applicable
Author

try rather something like this:

count({<EventId={"=minute(EndTime-StartTime)<=10"}>}EventId)

regards

Darek

Not applicable
Author

Thanks. The chart is at least showing something. The problem is that it isn't workin properly.

I made a selection of 3 date time values see below:

EventIdStartTimeEndTime
118-08-2011 20:35:2518-8-2011 21:11:53
228-10-2012 10:44:2128-10-2012 10:56:36
331-8-2013 20:47:2031-8-2013 20:49:27

that means the minutes are:

EventIdminute(EndTime-StartTime)
136
212
32

so the gauge chart should show 33,33...% but it is showing 100%

any idea's?

Not applicable
Author

maybe:

count({<EventId={"=minute(EndTime-StartTime)<=10"}>}EventId)/count(EventId)

Not applicable
Author

that gives a value of 6,25%

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Can you add the difference between EndTime and StartTime as a column to your Events table? Its value should equal the expression your already applied, e.g. minute(EndTime-StartTime) AS DurationMinutes

Then your gauge expression becomes:

= count ({<DurationMinutes = {"<=10"}>} EventId)/count(EventId)

or if you want to make the minimum duration fexible, you can add a slider to set a variable called vMinDur, and your expression becomes:

= count({<DurationMinutes = {"<=$(vMinDur)"}>} EventId)/count(EventId)

Not applicable
Author

i think this 6,25 is not 33,33...% becouse "count(EventId)" is counting all EventId's not only the ones i have selected right?

Peter_Cammaert
Partner - Champion III
Partner - Champion III

IMHO this won't work, as a set is determined before the resulting object is calculated on the set result.

That means that you try to stuff a lot of data in a single =minutes() expression.

Not applicable
Author

try:

count({<EventId={"=minute(EndTime-StartTime)<=10"}>}distinct EventId)/count(distinct EventId)

Not applicable
Author

i tried. Problem is that in the database all the records are its saved like this:

EventIdTypeTime
1StartTime18-08-2011 20:35:25
2StartTime28-10-2012 10:44:21
2EndTime28-10-2012 10:56:36
3StartTime31-8-2013 20:47:20
1EndTime18-8-2011 21:11:53
3EndTime31-8-2013 20:49:27

They are saved with a type and a time.

My load script is like this now:

Times:

LOAD EventId,

    Time as StartTime;

SQL SELECT *

FROM "Datebase".dbo.ActionTimes

WHERE Type = 'StartTime';

Times:

LOAD EventId,

    Time as EndTime;

SQL SELECT *

FROM "Datebase".dbo.ActionTimes

WHERE Type = 'EndTime';

If you have any idea's...