Calculation based on previous row

More
12 years 6 months ago #1969 by Scott
Hello

I am trying to calculate the stock (new column) based on previous row
if the Article=prevArticle AND Store=prevStore .

Date,Article,Store,Movement,Qty
12-01-2011,Banana001,aaa,In,21
13-01-2011,Banana001,aaa,in,82
13-01-2011,Banana001,aaa,out,180
13-01-2011,Banana001,bbb,in,121
14-01-2011,Banana001,bbb,out,51

My dream result text file is:

Date,Article,Store,TypeMovement,Qty,Stock
12-01-2011,Banana001,aaa,In,21,21
13-01-2011,Banana001,aaa,In,8,29
13-01-2011,Banana001,aaa,out,18,11
13-01-2011,Banana001,bbb,in,12,23
14-01-2011,Banana001,bbb,out,5,18

Any Help is welcome

John Scott

Please Log in or Create an account to join the conversation.

More
12 years 6 months ago #1970 by admin
Hello

This can be done by using 'running total' function

I have created a working example for you

extract all files into c:\support directory

Peter

Mike
ETL Architect
Attachments:

Please Log in or Create an account to join the conversation.