Page 1 of 1
Datastage
Posted: Thu Oct 17, 2013 6:42 pm
by Jones Sam
Hi All,
I have file which has values in a column like below.
col
100
250
300
500
I need to compare if row 1(100)> row 2(250) and row 2(250)> row 3(300)and row 3(300) > row 4 (500),,
Basically I am trying to find if the next row value in a column is greater than the current row value of the same column... If they are increasing from first to last value in the column then send it to a file.
Posted: Thu Oct 17, 2013 7:26 pm
by ray.wurlod
Welcome aboard.
This is not really an ETL task, but you can readily use stage variables in a Transformer stage to keep track of the previous row's value(s) in order to effect your comparison(s).
Another stage variable can be used to monitor your "first to last" (begin true, set to false on any exception) and this could form the constraint on the output link to the file.
Posted: Sun Oct 20, 2013 12:59 pm
by Jones Sam
Hi
we can do this is server job with stage variable as below.
stagevar1=RowProcGetPreviousValue(input.column)
stagevar2=input.column
if(stagevar2<stagevar1) then "yes increasing" else "no"
I tried in parallel job using stage variable but not successful.
Please share your thoughts.
Thanks in advance..
Posted: Sun Oct 20, 2013 3:19 pm
by chulett
Stage variables work the same in Parallel and Server, what was 'not successful' about your attempt? What exactly did you try? Did you run the Parallel job on a single node? While not required it does simplify things.
Posted: Wed Oct 23, 2013 5:25 pm
by Jones Sam
Hi Craig
I tried with two stage variables.
PreviousValue = CurrentValue
CurrentValue = input.column
if (CurrentValue < PreviousValue) then ""
Here initially currentvalue does not hold any values then the column values are assigned to previousval stage variable to perform comparision.
I tried with 2 node configuration.
Posted: Wed Oct 23, 2013 5:36 pm
by ray.wurlod
You must perform the comparison before the "remembering" stage variable is executed.
Code: Select all
svCurrentValue <--- input column
svIsIncreasing <--- (svCurrentValue > svPreviousValue)
svPreviousValue <--- input column
(You don't actually need svCurrentValue.)
Use the value of svIsIncreasing in your constraint logic.