Friday, February 24, 2012

Copy values from previous row

I'm guessing this is a fairly straight forward need, but want to make sure I am using the correct set of tasks:

In the dataflow, some values I need to carry forward from the previous row, such as a balance that I need to carry forward for the current customer record. This is similar to a running total, only I am not summing anything, but just carrying over from the previous records value (assuming dataset is sorted correctly, first by customer #, then by date).

Do I need the Dervied Column transform, and use a variable to store the previous value, or is there another transform that would be better suited?

Thanks

Kory

as far as i know, the derived column transformation cannot store a value in a variable. your problem seems to cry out for a script component or custom component solution.

i hope this helps.

|||I would do this in a T-SQL, Stored Procedure, or Execute SQL Task, avoiding a cursor. I worked on a SQL script like this once and avoided using a cursor by using an incremented identity field.|||

KoryS wrote:

I'm guessing this is a fairly straight forward need, but want to make sure I am using the correct set of tasks:

In the dataflow, some values I need to carry forward from the previous row, such as a balance that I need to carry forward for the current customer record. This is similar to a running total, only I am not summing anything, but just carrying over from the previous records value (assuming dataset is sorted correctly, first by customer #, then by date).

Do I need the Dervied Column transform, and use a variable to store the previous value, or is there another transform that would be better suited?

Thanks

Kory

I think you're going to need an asynchronous script transform in order to achieve that.

-Jamie

No comments:

Post a Comment