Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
Giel0
Contributor
Contributor

Copy data from previous row

Hey all,

I have a dataset with stock levels per day from last year till now. However, from a certain date (30-10-2021) there is no stock level measured every sunday. So I would like to copy the stock level from the saturday to the sunday (as there are no transaction in the weekends). 

After reading some related topics tried several options but it doesn't work. See attached an example dataset for one articlenumber (there are multiple article numbers in the actual dataset).

What I tried in script:

1. If(Weekdag = 'zo' and Date >= '30-10-2021', Peek(aantalNew), aantal) as aantalNew

2. If(Weekdag = 'zo' and Date >= '30-10-2021', Peek(aantalNew,-1), aantal) as aantalNew

However, this gives me the same output as sum(aantal). 

What am I doing wrong?

 

 

Labels (2)
2 Replies
Mark_Little
Luminary
Luminary

HI  @Giel0 

I would try 

If(Weekdag = 'zo' and Date >= '30-10-2021', Previous(aantalNew), aantal) as aantalNew

Giel0
Contributor
Contributor
Author

Hey @Mark_Little ,

I tried your solution but first I got the error message 'couldn't found aantalNew'.  So tried below formula but again get the same output as sum(aantal)

If(Weekdag = 'zo' and Date >= '30-10-2021', Previous(aantal), aantal) as aantalNew