Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
mherdt1992
Contributor II
Contributor II

Shift Column up by one row

Hello friends,

i hope you can help me, i have the following question :

How can I move a list one row up?

I have the Origin  Column : "myTimeStamp"  and would like to create a second column but shift it up by one row.

I want to calculate the time differences

I hope you can help me.

If you don't have a script solution, I would also be happy with a nonscript solution.

The solution should look like this:

sniptimestamp.PNG

 

Thanks !

1 Solution

Accepted Solutions
sunny_talwar

Then all you need to do is to sort first by username and then timestamp desc. and add an if statement to the peek function like this

If(username = previous(username), peek('TimeStamp'), 0) as Next_TimeStamp

View solution in original post

6 Replies
sunny_talwar

You can sort the table in the script in descending order and then use Peek() or Previous function to pull the value from the previous row

mherdt1992
Contributor II
Contributor II
Author

like

Load myTimeStamp,

Peek(myTimeStamp,-1) ?

sunny_talwar

Yup, something along those lines... but make sure to order the timestamp in descending order. Also, do you have another dimension which would restart this process? or do you want to stamp the next timestamp across the whole data set regardless of any other dimension?

mherdt1992
Contributor II
Contributor II
Author

yes i have also have the user names as a dimension.

5 users have a schedule every day.

my initial goal is, to calculate the time difference and create a schedule plan, to visually see their schedule

sunny_talwar

Then all you need to do is to sort first by username and then timestamp desc. and add an if statement to the peek function like this

If(username = previous(username), peek('TimeStamp'), 0) as Next_TimeStamp

mherdt1992
Contributor II
Contributor II
Author

That helps, thank you very much!