Hi,
I would like to add records in datastage in such a way that I obtain the cumulative sum in the output column. So for example, if the
Input dataset
YEAR AMOUNT
2007 10
2008 20
2009 5
2010 15
2011 30
Output dataset should look like this:(CUMSUM is the output column)
YEAR AMOUNT CUMSUM
2007 10 10
2008 20 30
2009 5 35
2010 15 50
2011 30 80
If anyone can give me some suggestion as to how to go about achieving this, it would be great.
Thanks,
dscon9128
Addition of Rows in Datastage
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 27
- Joined: Thu Mar 20, 2008 11:55 am
Re: Addition of Rows in Datastage
You can use Stage variable...
initial Stage var i =0
i=i+inrowlink
your outputlink=i
initial Stage var i =0
i=i+inrowlink
your outputlink=i
Thanks.
"Creativity is the ability to use your available resources to their fullest."
"Creativity is the ability to use your available resources to their fullest."
Check out hash partitioning and sorting, transforms and stage variables.
Hash partitioning gets the "like" data in the same partition, sort it in the right order, store the previous cumulative in a stage variable, add the stage variable to the new input row, output the row with the new cumulative.
Use stage variables to detect when to zero out the cumulative.
Hash partitioning gets the "like" data in the same partition, sort it in the right order, store the previous cumulative in a stage variable, add the stage variable to the new input row, output the row with the new cumulative.
Use stage variables to detect when to zero out the cumulative.
Check out hash partitioning and sorting, transforms and stage variables.
Hash partitioning gets the "like" data in the same partition, sort it in the right order, store the previous cumulative in a stage variable, add the stage variable to the new input row, output the row with the new cumulative.
Use stage variables to detect when to zero out the cumulative.
Hash partitioning gets the "like" data in the same partition, sort it in the right order, store the previous cumulative in a stage variable, add the stage variable to the new input row, output the row with the new cumulative.
Use stage variables to detect when to zero out the cumulative.