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: 
Anonymous
Not applicable

Assigning values

Sorry i don't know to keep any specific title for this thread..

Consider 3 columns,

Name, rows, start_time

Namerowstime
a1016/10/2016 10:54:22 am
a2016/10/2016 10:56:21 am
b3016/10/2016 10:59:10 am
b1016/10/2016 11:02:12 am
c2016/10/2016 11:10:23 am

Consider a is process which ran at 16/10/2016 10:54:22 am, as it is the least minimum time in this table, it should be the starting for all the process, so the  start_time for process a is 16/10/2016 10:54:22 am end_time should be same 16/10/2016 10:54:22 am.

a with 20 rows should have start_time as 16/10/2016 10:54:22 am and end_time as 16/10/2016 10:56:21 am

b with 30 rows should have start_time as 16/10/2016 10:56:21 am am and end_time as 16/10/2016 10:59:10 am

b with 10 rows should have start_time as 16/10/2016 10:59:10 am am am and end_time as 16/10/2016 11:02:12 am

c with 20 rows should have start_time as 16/10/2016 11:02:12 am am am am and end_time as 16/10/2016 11:10:23 am



O/p Table :


Namerowsstart_timeend_time
a106/10/2016 10:54:22 am6/10/2016 10:54:22 am
a206/10/2016 10:54:22 am16/10/2016 10:56:21 am
b30
16/10/2016 10:56:21 am
16/10/2016 10:59:10 am
b1016/10/2016 10:59:10 am16/10/2016 11:02:12 am
c2016/10/2016 11:02:12 am16/10/2016 11:10:23 am


Please help me in doing this.

1 Solution

Accepted Solutions
tamilarasu
Champion
Champion

That's the reason I used order by clause. The above code works fine even If you change the order.   Have a look at the attachment.

View solution in original post

4 Replies
tamilarasu
Champion
Champion

Hi Kishore,

Kindly check the below code in your original file. Let me know if any issues.

Data:
LOAD * INLINE [
Name, rows, time
a, 10, 16/10/2016 10:54:22 am
a, 20, 16/10/2016 10:56:21 am
b, 30, 16/10/2016 10:59:10 am
b, 10, 16/10/2016 11:02:12 am
c, 20, 16/10/2016 11:10:23 am
]
;

Final:
Load Name,
rows,
If(RowNo()=1,time, If(Rowno()=2,Peek('start_time'), Previous(time))) as start_time,
time as end_time
Resident Data order by time,Name, rows;

DROP Table Data;


Output:

Capture.PNG

Anonymous
Not applicable
Author

thanks for your help.

What if it is not in an order. now the Name which is having minimum time should come first.

in this,

Namerowstime
a1016/10/2016 10:54:22 am
b3016/10/2016 10:59:10 am
a2016/10/2016 10:56:21 am
c2016/10/2016 11:10:23 am
b1016/10/2016 11:02:12 am

O/P :

a          10          16/10/2016 10:54:22 am          16/10/2016 10:54:22 am

a          20          16/10/2016 10:54:22 am          16/10/2016 10:56:21 am

b          30          16/10/2016 10:56:21 am          16/10/2016 10:59:10 am

and so on...


How would i get now?

tamilarasu
Champion
Champion

That's the reason I used order by clause. The above code works fine even If you change the order.   Have a look at the attachment.

Chanty4u
MVP
MVP

you are great bro