Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Value occures over a time span

Hi!

Need some help to solve this problem.

I have a table with ID, Date and Value, as below and I want to count as True every non-zero value if it occure for more than 5 minutes. e g the value 1 occure for more than 5 minutes between 2012-01-10 21:11:16 and 21:17:26 and once again between 21:21:36 and 21:29:20.

IDDateValue
343192012-01-10  21:09:430
343192012-01-10  21:11:161
343192012-01-10  21:12:181
343192012-01-10  21:15:551
343192012-01-10  21:17:261
343192012-01-10  21:18:300
343192012-01-10  21:21:361
343192012-01-10  21:23:081
343192012-01-10  21:24:411
343192012-01-10  21:29:201
343202012-01-10  22:08:510
343202012-01-10  22:11:260
343202012-01-10  22:14:012
343202012-01-10  22:15:032
343202012-01-10  22:18:392
343202012-01-10  22:20:482
343202012-01-10  22:23:231
343202012-01-10 22:25:210
343202012-01-10 22:26:181

/Peter

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Maybe like this:

TEST:

LOAD *,

    if(num#(interval(Date-BlockStartDate,'mm')) >= 5 and Value,AutoNumber(BlockStartDate)) as OverTimeBlockNr;

LOAD ID,

     Date,

     Value,

     if(peek(Value)=0 and Value, Date, peek(BlockStartDate)) as BlockStartDate 

FROM

[http://community.qlik.com/thread/68926?tstart=0]

(html, codepage is 1252, embedded labels, table is @1);

Then a in the front end, an expression like

=count(distinct OverTimeBlockNr)

will return your result.

View solution in original post

2 Replies
swuehl
MVP
MVP

Maybe like this:

TEST:

LOAD *,

    if(num#(interval(Date-BlockStartDate,'mm')) >= 5 and Value,AutoNumber(BlockStartDate)) as OverTimeBlockNr;

LOAD ID,

     Date,

     Value,

     if(peek(Value)=0 and Value, Date, peek(BlockStartDate)) as BlockStartDate 

FROM

[http://community.qlik.com/thread/68926?tstart=0]

(html, codepage is 1252, embedded labels, table is @1);

Then a in the front end, an expression like

=count(distinct OverTimeBlockNr)

will return your result.

Not applicable
Author

Thanks for quick answer, it works perfect.

/Peter