Now, for the first occurence of each Cust_ID, I need to multiply Value by 5. However, for subsequent occurence of each customer's ID, I just pass the values as they are. So, my result looks like -
the simplest and most efficient method would be to sort the incoming stream by Cust_ID and then to use a stage variable to store the last Cust_ID value and to do a comparison on this value with the current Cust_ID to see if this has changed in order to do your x5 computation.
the simplest and most efficient method would be to sort the incoming stream by Cust_ID and then to use a stage variable to store the last Cust_ID value and to do a comparison on this value with the current Cust_ID to see if this has changed in order to do your x5 computation.
I do this a lot. It relies on the fact that stage variables are evaluated in the order that they appear, so if you use the value of one stage variable in the derivation of another stage variable that is above it, then it gets the value from the previous record.
I can't remember whether or not svKey is null when the first record is processed. I have seen multiple NULL keys treated as separate key values, so you might want to code around that.
There is no necessary to code around that because Cust_Id will never be NULL. I think when the first record is processed, the stage variable (svKey) doesn't hold any value (probably NULL).
So, when you process the first record, always the OLDSVKEY<>SVKEY.
naveendronavalli wrote:I think when the first record is processed, the stage variable (svKey) doesn't hold any value (probably NULL).
Don't "think" - know what it is by explicitly setting it's Initial Value in the stage variables property box.
And set it to something non-null that you know will be different than any first value coming in so the first 'not equal' check will be true. Keep in mind the fact that - if the initial value of the stage variable is null - that first not equal check will take the false path.
-craig
"You can never have too many knives" -- Logan Nine Fingers
the simplest and most efficient method would be to sort the incoming stream by Cust_ID and then to use a stage variable to store the last Cust_ID value and to do a comparison on this value with the current Cust_ID to see if this has changed in order to do your x5 computation.