Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Rank and check a field and get sum

If any of the date and time field is null then picking time shud be blank...

1 Solution

Accepted Solutions
sunny_talwar

May be this

Table:

LOAD *,

RangeSum([Confirmation date first step], [Confirmation time first step]) as [Confirmation datetime first step],

RangeSum([Confirmation date], [Confirmation time]) as [Confirmation datetime],

AutoNumber(RowNo(), [TO Nr.]) as Rank_New,

If(Len(Trim([Confirmation date first step])) = 0, 1, 0) as NullFlag;

LOAD * INLINE [

    TO Nr., TO item, Material, Confirmation date first step, Confirmation time first step, Rank, Confirmation date, Confirmation time

    155214, 1, 422203700110, 22-2-2018, 13:19:00, 1, 22-2-2018, 13:19:39

    155214, 2, 423509910411, 22-2-2018, 13:20:53, 2, 22-2-2018, 14:09:05

    155214, 3, 422200253991, 22-2-2018, 13:40:28, 3, 22-2-2018, 13:40:28

    155214, 4, 422200253991, 22-2-2018, 13:42:47, 4, 22-2-2018, 14:09:05

    155214, 5, 422203426171, 22-2-2018, 13:47:25, 5, 22-2-2018, 14:09:05

    155214, 6, 422203534323, 22-2-2018, 14:08:53, 6, 22-2-2018, 14:09:05

    155214, 7, 422203700110, 22-2-2018, 14:09:57, 7, 22-2-2018, 14:10:58

    155214, 8, 422200253991, 22-2-2018, 14:10:45, 8, 22-2-2018, 14:10:45

    155214, 9, 422200253991,   , , 9, 22-2-2018, 14:10:45

];


FinalTable:

LOAD *,

Interval(If(NullFlag = 0,

   If([Confirmation datetime] = Previous([Confirmation datetime]), Previous([Confirmation datetime first step]) - [Confirmation datetime first step], [Confirmation datetime] - [Confirmation datetime first step]))) as [Picking Time]

Resident Table

Order By [TO Nr.], [Confirmation datetime first step] desc;


DROP Table Table;

View solution in original post

4 Replies
sunny_talwar

It would be helpful if you can provide the sample data as well.... so that we can test it out

Anonymous
Not applicable
Author

If any of the date and time files is empty then picking time shud be blank   

TO Nr.
TO itemMaterialConfirmation date first stepConfirmation time first stepRankConfirmation dateConfirmation timePicking time
155214142220370011022-2-201813:19:00122-2-201813:19:390:00:39
155214242350991041122-2-201813:20:53222-2-201814:09:050:48:12
155214342220025399122-2-201813:40:28322-2-201813:40:280:00:00
155214442220025399122-2-201813:42:47422-2-201814:09:050:04:38
155214542220342617122-2-201813:47:25522-2-201814:09:050:21:28
155214642220353432322-2-201814:08:53622-2-201814:09:050:00:12
155214742220370011022-2-201814:09:57722-2-201814:10:580:01:01
155214842220025399122-2-201814:10:45822-2-201814:10:45  0:00:00
1552151422203700110 0:00:00123-2-20180:10:22
1552161422200253998 1:00:00123-2-20181:10:22
sunny_talwar

May be this

Table:

LOAD *,

RangeSum([Confirmation date first step], [Confirmation time first step]) as [Confirmation datetime first step],

RangeSum([Confirmation date], [Confirmation time]) as [Confirmation datetime],

AutoNumber(RowNo(), [TO Nr.]) as Rank_New,

If(Len(Trim([Confirmation date first step])) = 0, 1, 0) as NullFlag;

LOAD * INLINE [

    TO Nr., TO item, Material, Confirmation date first step, Confirmation time first step, Rank, Confirmation date, Confirmation time

    155214, 1, 422203700110, 22-2-2018, 13:19:00, 1, 22-2-2018, 13:19:39

    155214, 2, 423509910411, 22-2-2018, 13:20:53, 2, 22-2-2018, 14:09:05

    155214, 3, 422200253991, 22-2-2018, 13:40:28, 3, 22-2-2018, 13:40:28

    155214, 4, 422200253991, 22-2-2018, 13:42:47, 4, 22-2-2018, 14:09:05

    155214, 5, 422203426171, 22-2-2018, 13:47:25, 5, 22-2-2018, 14:09:05

    155214, 6, 422203534323, 22-2-2018, 14:08:53, 6, 22-2-2018, 14:09:05

    155214, 7, 422203700110, 22-2-2018, 14:09:57, 7, 22-2-2018, 14:10:58

    155214, 8, 422200253991, 22-2-2018, 14:10:45, 8, 22-2-2018, 14:10:45

    155214, 9, 422200253991,   , , 9, 22-2-2018, 14:10:45

];


FinalTable:

LOAD *,

Interval(If(NullFlag = 0,

   If([Confirmation datetime] = Previous([Confirmation datetime]), Previous([Confirmation datetime first step]) - [Confirmation datetime first step], [Confirmation datetime] - [Confirmation datetime first step]))) as [Picking Time]

Resident Table

Order By [TO Nr.], [Confirmation datetime first step] desc;


DROP Table Table;

sunny_talwar

Here you go

Table:

LOAD *,

RangeSum([Confirmation date first step], [Confirmation time first step]) as [Confirmation datetime first step],

RangeSum([Confirmation date], [Confirmation time]) as [Confirmation datetime],

AutoNumber(RowNo(), [TO Nr.]) as Rank_New,

If(Len(Trim([Confirmation date first step])) = 0, 1, 0) as NullFlag;

LOAD * INLINE [

    TO Nr., TO item, Material, Confirmation date first step, Confirmation time first step, Rank, Confirmation date, Confirmation time, F9

    155214, 1, 422203700110, 22-2-2018, 13:19:00, 1, 22-2-2018, 13:19:39

    155214, 2, 423509910411, 22-2-2018, 13:20:53, 2, 22-2-2018, 14:09:05

    155214, 3, 422200253991, 22-2-2018, 13:40:28, 3, 22-2-2018, 13:40:28

    155214, 4, 422200253991, 22-2-2018, 13:42:47, 4, 22-2-2018, 14:09:05

    155214, 5, 422203426171, 22-2-2018, 13:47:25, 5, 22-2-2018, 14:09:05

    155214, 6, 422203534323, 22-2-2018, 14:08:53, 6, 22-2-2018, 14:09:05

    155214, 7, 422203700110, 22-2-2018, 14:09:57, 7, 22-2-2018, 14:10:58

    155214, 8, 422200253991, 22-2-2018, 14:10:45, 8, 22-2-2018, 14:10:45

    155215, 1, 422203700110, , 0:00:00, 1, 23-2-2018, 0:10:22,

    155216, 1, 422200253998, , 1:00:00, 1, 23-2-2018, 1:10:22

];


FinalTable:

LOAD *,

Interval(If(NullFlag = 0,

  If([Confirmation datetime] = Previous([Confirmation datetime]), Previous([Confirmation datetime first step]) - [Confirmation datetime first step], [Confirmation datetime] - [Confirmation datetime first step]))) as [Picking Time]

Resident Table

Order By [TO Nr.], [Confirmation datetime first step] desc;


DROP Table Table;

Capture.PNG