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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
kavieweg
Partner - Creator
Partner - Creator

New Sequence ID depending on the time sequence

I have a list of orders per Date, ID and RK-ID. Dependig on the Time sequence I would like to add a new column NewSequenceID with the result in the table. Who can help me to solve this in the loadscript or in the table ?

DateOrderIDIDRK-IDTimeNewSequenceID
23.03.202115691486N39273675410:001
23.03.202115691488N39273675410:032
23.03.202115691485N39273675410:093
23.03.202115691487N39273675411:094
23.03.202115691489N39273675411:094
23.03.202115691492N39273675413:095
23.03.202115691491N39273675414:096
23.03.202115691490N39273675415:097

 

Thanks in advance,

Mathias

9 Replies
Anil_Babu_Samineni
MVP
MVP

Perhaps this?

LOAD Date,
OrderID,
ID,
[RK-ID],
Time,
AutoNumber(Time) as NewSequenceID
FROM
[https://community.qlik.com/t5/New-to-Qlik-Sense/New-Sequence-ID-depending-on-the-time-sequence/m-p/1...]
(html, utf8, UserAgent is 'Mozilla/5.0', embedded labels, table is @1);

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Saravanan_Desingh
MVP
MVP

Try this,

tab1:
LOAD * INLINE [
    Date, OrderID, ID, RK-ID, Time
    23.03.2021, 15691486, N392, 736754, 10:00
    23.03.2021, 15691488, N392, 736754, 10:03
    23.03.2021, 15691485, N392, 736754, 10:09
    23.03.2021, 15691487, N392, 736754, 11:09
    23.03.2021, 15691489, N392, 736754, 11:09
    23.03.2021, 15691492, N392, 736754, 13:09
    23.03.2021, 15691491, N392, 736754, 14:09
    23.03.2021, 15691490, N392, 736754, 15:09
];

tab2:
NoConcatenate
LOAD *, If(Peek(Date)&Peek(Time)=Date&Time,Peek(NewSequenceID),RangeSum(Peek(NewSequenceID),1)) As NewSequenceID
Resident tab1
Order By Date, Time, ID, OrderID;

Drop Table tab1;
Saravanan_Desingh
MVP
MVP

Output:

commQV54.PNG

kavieweg
Partner - Creator
Partner - Creator
Author

Hey, this is working quite well 🙂 THANKS

But I forgot to tell that i also have other values in the table

if I add another ID, RK ID for the same or other day

22.03.2021

15691231

N400

6754

14:09

1

22.03.2021

15693423

N400

6754

15:09

2

 

21.03.2021

874837

N500

736754

14:09

1

21.03.2021

743878

N500

736754

15:09

2

21.03.2021

743873

N500

736754

15:09

2

 

so i have to do the sorting by time  for each Date, ID and RK-ID

rwunderlich
MVP
MVP

If you use @Anil_Babu_Samineni solution with AutoNumber(), you don't have to worry about sorting at all. 

-Rob

kavieweg
Partner - Creator
Partner - Creator
Author

I tried this, but AutoNumber doesnt work correctly with my DateTime Format....

kavieweg
Partner - Creator
Partner - Creator
Author

I tried this, but AutoNumber doesnt work correctly with my DateTime Format....

Saravanan_Desingh
MVP
MVP

Try this,

tab1:
LOAD * INLINE [
    Date, OrderID, ID, RK-ID, Time
    23.03.2021, 15691486, N392, 736754, 10:00
    23.03.2021, 15691488, N392, 736754, 10:03
    23.03.2021, 15691485, N392, 736754, 10:09
    23.03.2021, 15691487, N392, 736754, 11:09
    23.03.2021, 15691489, N392, 736754, 11:09
    23.03.2021, 15691492, N392, 736754, 13:09
    23.03.2021, 15691491, N392, 736754, 14:09
    23.03.2021, 15691490, N392, 736754, 15:09
    22.03.2021, 15691231, N400, 6754, 14:09
    22.03.2021, 15693423, N400, 6754, 15:09
    21.03.2021, 874837, N500, 736754, 14:09
    21.03.2021, 743878, N500, 736754, 15:09
    21.03.2021, 743873, N500, 736754, 15:09
];

tab2:
NoConcatenate
LOAD *, If(Peek(Date)<>Date,1,If(Peek(Date)&Peek(Time)=Date&Time,Peek(NewSequenceID),RangeSum(Peek(NewSequenceID),1))) As NewSequenceID
Resident tab1
Order By Date, Time, [RK-ID], OrderID;

Drop Table tab1;
Saravanan_Desingh
MVP
MVP

Output:

commQV55.PNG