Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Consecutive data records

Hi All,

I have 2 queries highlighted in bold.

Below is the attached data:

1. Firstly I want to add an extra column say Count- which calculates the consecutive number of failures else write 1

    

IDHostTimeStatusCount---Not in data
457abc15/04/2016  1:47:19 AMSuccess1
458abc15/04/2016  1:47:25 AMFailure1
459abc15/04/2016  1:47:28 AMSuccess1
460abc15/04/2016  2:19:12 AMSuccess1
461abc15/04/2016  3:25:07 AMSuccess1
462abc15/04/2016  7:01:43 AMFailure1
463abc15/04/2016  7:01:43 AMFailure2
464abc15/04/2016  7:01:43 AMFailure3
465abc15/04/2016  7:01:43 AMFailure4
466abc15/04/2016  3:12:03 PMFailure5
467abc15/04/2016  3:12:03 PMFailure6
468abc16/04/2016  1:13:20 AMSuccess1
469abc16/04/2016  1:13:59 AMSuccess1
470abc16/04/2016  7:00:24 AMFailure1
471abc16/04/2016  7:00:24 AMFailure2
472abc16/04/2016  7:00:26 AMFailure3
473abc16/04/2016  7:01:20 AMFailure4
474abc16/04/2016  7:01:20 AMFailure5
475abc16/04/2016  7:01:21 AMFailure6
476abc16/04/2016  5:51:15 PMFailure7
477abc16/04/2016  5:51:15 PMFailure8
478abc16/04/2016  7:05:46 PMSuccess1
479abc16/04/2016  9:11:40 PMSuccess1
480abc16/04/2016  9:18:48 PMSuccess1
481abc16/04/2016 10:23:32 PMSuccess1
482abc17/04/2016 12:00:25 AMFailure1
483abc17/04/2016 12:00:25 AMFailure2
484abc17/04/2016 12:00:25 AMFailure3
485abc17/04/2016 12:00:25 AMFailure4
486abc17/04/2016  9:09:47 AMSuccess1
487abc17/04/2016 11:08:55 AMSuccess1
488abc18/04/2016  2:27:24 AMSuccess1
489abc18/04/2016  2:33:15 AMSuccess1
490abc18/04/2016  3:52:05 AMSuccess1


2.  My second  Requirement is to get the count of consecutive failures and start time and end time of consecutive failures

So, according to my requirement -- the resultant should be as below:

Host# of Consecutive FailureStart TimeEnd Time
abc615/04/2016  7:01:43 AM15/04/2016  3:12:03 PM
abc816/04/2016  7:00:24 AM16/04/2016  5:51:15 PM
abc417/04/2016  12:00:25 AM17/04/2016  12:00:25 AM

Pls help.

Regards,

Anjali Gupta

1 Solution

Accepted Solutions
sunny_talwar

1st and 2nd Requirement

Table:

LOAD ID,

    Host,

    Time,

    Status

FROM

[https://community.qlik.com/thread/213935]

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

FinalTable:

LOAD *,

  If(Status = 'Failure',

    If(Status = Peek('Status'), RangeSum(Peek('Count'), 1), 1), 1) as Count,

    If(Status <> Peek('Status'), RangeSum(Peek('Flag'), 1), Alt(Peek('Flag'), 1)) as Flag

Resident Table

Order By Time;

DROP Table Table;


Capture.PNG

View solution in original post

5 Replies
sunny_talwar

First part of the requirement:

Table:

LOAD ID,

    Host,

    Time,

    Status

FROM

[https://community.qlik.com/thread/213935]

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

FinalTable:

LOAD *,

  If(Status = 'Failure',

    If(Status = Peek('Status'), RangeSum(Peek('Count'), 1), 1), 1) as Count,

    If(Status = 'Failure', If(Status <> Peek('Status'), 1),

      If(Status <> Peek('Status'), 2)) as Flag

Resident Table

Order By Time;

DROP Table Table;

sunny_talwar

1st and 2nd Requirement

Table:

LOAD ID,

    Host,

    Time,

    Status

FROM

[https://community.qlik.com/thread/213935]

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

FinalTable:

LOAD *,

  If(Status = 'Failure',

    If(Status = Peek('Status'), RangeSum(Peek('Count'), 1), 1), 1) as Count,

    If(Status <> Peek('Status'), RangeSum(Peek('Flag'), 1), Alt(Peek('Flag'), 1)) as Flag

Resident Table

Order By Time;

DROP Table Table;


Capture.PNG

Not applicable
Author

Hi Sunny,

Thanks for your help.

If you can attach the qvw for me to do the 2nd Requirement it would me great.

Also, for the 2nd requirement I don't want the failures with # of Consecutive Failures = 1.

I will restrict it in the chart.


Regards,

Anjali Gupta

sunny_talwar

It was attached above, but reattaching it after making the asked modifications

Capture.PNG

Not applicable
Author

Thanks a lot sunny.

You are a genious...

Regards,

Anjali Gupta