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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Date flags calculation error

Hi Friends,

i have some fields like Branch, Case,Down_since and Up_Since, now my issue is where ever Up_Since is null, i need to captured that down since time and more than that down since time in Branch ,calculated as flag,I'm attaching one excel sample data in that manually i created on column OutPut.i'm expecting output like that. Please help me out.

Capture.JPG

1 Solution

Accepted Solutions
sunny_talwar

May be this:

Table:

LOAD IP_Address,

    BranchCode,

    Case_ID,

    Down_Since,

    Up_Since

FROM

CH146_20160405_144011.xls

(biff, embedded labels, table is Sheet1$);

FinalTable:

LOAD *,

  If(IP_Address = Peek('IP_Address') and BranchCode = Peek('BranchCode'),

  If(Up_Since = '-', 1, Peek('Flag')), 0) as Flag

Resident Table

Order By IP_Address, BranchCode, Down_Since;

DROP Table Table;

or this if its actually Null

Table:

LOAD IP_Address,

    BranchCode,

    Case_ID,

    Down_Since,

    Up_Since

FROM

CH146_20160405_144011.xls

(biff, embedded labels, table is Sheet1$);

FinalTable:

LOAD *,

If(IP_Address = Peek('IP_Address') and BranchCode = Peek('BranchCode'),

  If(Len(Trim(Up_Since)) = 0, 1, Peek('Flag')), 0) as Flag

Resident Table

Order By IP_Address, BranchCode, Down_Since;

DROP Table Table;

View solution in original post

3 Replies
sunny_talwar

May be this:

Table:

LOAD IP_Address,

    BranchCode,

    Case_ID,

    Down_Since,

    Up_Since

FROM

CH146_20160405_144011.xls

(biff, embedded labels, table is Sheet1$);

FinalTable:

LOAD *,

  If(IP_Address = Peek('IP_Address') and BranchCode = Peek('BranchCode'),

  If(Up_Since = '-', 1, Peek('Flag')), 0) as Flag

Resident Table

Order By IP_Address, BranchCode, Down_Since;

DROP Table Table;

or this if its actually Null

Table:

LOAD IP_Address,

    BranchCode,

    Case_ID,

    Down_Since,

    Up_Since

FROM

CH146_20160405_144011.xls

(biff, embedded labels, table is Sheet1$);

FinalTable:

LOAD *,

If(IP_Address = Peek('IP_Address') and BranchCode = Peek('BranchCode'),

  If(Len(Trim(Up_Since)) = 0, 1, Peek('Flag')), 0) as Flag

Resident Table

Order By IP_Address, BranchCode, Down_Since;

DROP Table Table;

Anonymous
Not applicable
Author

Hi Sunny,

Thanks for reply, Your code is Working fine.

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

If Sunny's answer solved your problem then please mark it as the correct answer.


talk is cheap, supply exceeds demand