I need the below output please let me know how to do in ds
Input
101 1000
101 2000
101 3000
201 1000
201 4000
Output
101 1000
101 3000
101 6000
201 1000
201 5000
Datastage Senario?
Moderators: chulett, rschirm, roy
Reply
In Transformer Hash Partition & Sort COL1 ascending.
Dont partition sort only COL2 Ascending. Then use stage variables.
svsum : if DSLINK.COL1 = svCOL1old then svCOL2 + DSLINK.COL2 else DSLINK.COL2
svCOL1old : DSLINK.COL1
svCOL2 : svsum
Output Col1 : DSLINK.COL1
Output Col2 : svsum
Dont partition sort only COL2 Ascending. Then use stage variables.
svsum : if DSLINK.COL1 = svCOL1old then svCOL2 + DSLINK.COL2 else DSLINK.COL2
svCOL1old : DSLINK.COL1
svCOL2 : svsum
Output Col1 : DSLINK.COL1
Output Col2 : svsum
Last edited by ssnegi on Mon Mar 03, 2014 5:46 pm, edited 2 times in total.
Or use a Sort stage to generate a Key Change column on the first field and then all you need is:
And of course, mind your partitioning.
Code: Select all
svRunningTotal: If KeyChange then COL2 else svRunningTotal + COL2
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers