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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
ilanbaruch
Specialist
Specialist

time groups, game durration

Hi all,

I'm looking for a way to group gamers by game duration time.

in my script I have a calculate field 'GameDuration' :

Date(EndTime - StartTime, 'hh:mm:ss') as GameDuration

my groups calculated in the same load statement :

if( GameDuration <'00:03:00','0-3',If(GameDuratione >='00:03:00' and GameDuratione <'00:06:00','3-6','6+')) as DurationGroup

I get all kind of errors..

any ideas??

1 Solution

Accepted Solutions
Not applicable

Hi,

Did you copy past the expression from your script?

if( GameDuration <'00:03:00','0-3',If(GameDuratione >='00:03:00' and GameDuratione <'00:06:00','3-6','6+')) as DurationGroup


Change to


if( GameDuration <'00:03:00','0-3',If(GameDuration >='00:03:00' and GameDuration <'00:06:00','3-6','6+')) as DurationGroup


Also if you are writing this in the same load statement it would not work as GameDuration would not be available. You either need to reload the table or subsitute GameDuration with the formula some thing like:


if( (Date(EndTime - StartTime, 'hh:mm:ss')) < '00:03:00','0-3',If((Date(EndTime - StartTime, 'hh:mm:ss')) >= '00:03:00' and (Date(EndTime - StartTime, 'hh:mm:ss')) < '00:06:00','3-6','6+')) as DurationGroup



Regards


RL

View solution in original post

6 Replies
Anonymous
Not applicable

ilan,

Best way to do this is by using function IntervalMatch. This will help IntervalMatch

Marc.

hic
Former Employee
Former Employee

How and where do you want to define your groups? The answer affects which solution to choose...

A couple of tips:

  1. Use EndTime - StartTime as GameDuration during the development instead. Then you will get the duration as a number (in days). When you're done, you can format it as Interval(EndTime - StartTime,'hh:mm:ss') as GameDuration to make it prettier.
  2. Read Buckets

HIC

rubenmarin

Hi Ilan, Time and date funcions returns a number (with an string interpretation), if you want to compare in minutes you can declare a variable with the value of a minute and use it in the 'if' comparison:

LET vsMinute = Replace(1/1440, ',', '.'); //For me ',' is dec separator, to compare in if I need to change to '.'

if( GameDuration <$(vsMinute)*3,'0-3',If(GameDuratione >=$(vsMinute)*3 and GameDuratione <$(vsMinute)*6,'3-6','6+')) as DurationGroup

Not applicable

Hi,

Did you copy past the expression from your script?

if( GameDuration <'00:03:00','0-3',If(GameDuratione >='00:03:00' and GameDuratione <'00:06:00','3-6','6+')) as DurationGroup


Change to


if( GameDuration <'00:03:00','0-3',If(GameDuration >='00:03:00' and GameDuration <'00:06:00','3-6','6+')) as DurationGroup


Also if you are writing this in the same load statement it would not work as GameDuration would not be available. You either need to reload the table or subsitute GameDuration with the formula some thing like:


if( (Date(EndTime - StartTime, 'hh:mm:ss')) < '00:03:00','0-3',If((Date(EndTime - StartTime, 'hh:mm:ss')) >= '00:03:00' and (Date(EndTime - StartTime, 'hh:mm:ss')) < '00:06:00','3-6','6+')) as DurationGroup



Regards


RL

PrashantSangle

Hi,

If you are creating GameDuration in same load statement and in same load statement you are using GameDuration Field It wont work.

For using this newly created field you have to use resident load.

For Example:

Test:

Load *

Interval(EndTime - StartTime,'hh:mm:ss') as GameDuration

from tableName;

Final:

Load *

if(GameDuration<'00:03:00','0 - 3 Min', if(GameDuration>='00:03:00' and GameDuration>='00:06:00'),'0 - 6 Min ','6 +')) as DurationGroup

Resident Test;

Drop table Test;

Note: Also Read Bucket article written by Henric, It will help you.

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
ilanbaruch
Specialist
Specialist
Author

Thank you.