Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
rosey13478
Contributor II
Contributor II

Time Differences put into Categories

I have two date/time fields (BATime & AppTime), I need to be able to count how many people are in the following categories:

BATime is less than AppTime

BATime is within +/- 5 mins of AppTime

BATime is up to 30 mins after AppTime

BATime is up to 60 mins after AppTime

BATime is greater than 60 mins after AppTime

I have tried various calculations using interval to find the difference in minutes between the BATime and AppTime, the problem I am having is putting the time differences into the above categories.  I am going to show this info in a pie chart....hopefully!

Thanks

Labels (1)
1 Solution

Accepted Solutions
Not applicable

Hi rosey,

if your BATime and AppTime are both timestamps (in same table), you can easily calculate with them like this:

Diff = AppTime-BATime

With this in mind try to start (as an exercise) creating a straight table with for ex. two expressions "DiffTime" and "Category" like this:

"DiffTime":

AppTime-BATime (format it as an "interval" for better understanding of your expr "Cat")

and

"Cat":

if((AppTime-BATime) < '00:00:00','A',

if((AppTime-BATime) < '00:05:00', 'B',

if((AppTime-BATime) < '00:30:00', 'C', 'D'

)))

If you are familar with this, I would suggest you to put the whole calculating into the load-script. Then you are able to use your Time-Cat whereever you want, for ex. as an dimension in a pie chart ....

HtH

Roland

View solution in original post

2 Replies
Not applicable

Hi rosey,

if your BATime and AppTime are both timestamps (in same table), you can easily calculate with them like this:

Diff = AppTime-BATime

With this in mind try to start (as an exercise) creating a straight table with for ex. two expressions "DiffTime" and "Category" like this:

"DiffTime":

AppTime-BATime (format it as an "interval" for better understanding of your expr "Cat")

and

"Cat":

if((AppTime-BATime) < '00:00:00','A',

if((AppTime-BATime) < '00:05:00', 'B',

if((AppTime-BATime) < '00:30:00', 'C', 'D'

)))

If you are familar with this, I would suggest you to put the whole calculating into the load-script. Then you are able to use your Time-Cat whereever you want, for ex. as an dimension in a pie chart ....

HtH

Roland

rosey13478
Contributor II
Contributor II
Author

Thanks Roland,

I thought it should have been relatively simple, just couldn't work out the correct format. Your suggestion worked perfectly.

Thanks Again