Need Help to Implement Logic
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 21
- Joined: Mon Mar 16, 2009 3:59 am
Need Help to Implement Logic
Hi,
I am trying to implement the following scenario which came up as part of our recent requirements. I have stated the logic below.
We have a Product table which has with Product and Amount as it's attributes.
Product ID Amount
FX123 100
Ab234 200
XZ567 300
SD234 400
As per the logic we have to come up with a third column Adjusted Amount while loading the database which is as follows
Product ID Amount AdjAmt
FX123 100 Null
Ab234 200 100
XZ567 300 200
SD234 400 300
So we have to populate the first record AdjAmt as 'Null' and from second record onwards we have to take the amount from first record and so on.
I tried implementing with the help of stage variables but it didnot help.
Would appreciate if someone can provide some insight on the above logic.
Thanks
Vineet Singh
I am trying to implement the following scenario which came up as part of our recent requirements. I have stated the logic below.
We have a Product table which has with Product and Amount as it's attributes.
Product ID Amount
FX123 100
Ab234 200
XZ567 300
SD234 400
As per the logic we have to come up with a third column Adjusted Amount while loading the database which is as follows
Product ID Amount AdjAmt
FX123 100 Null
Ab234 200 100
XZ567 300 200
SD234 400 300
So we have to populate the first record AdjAmt as 'Null' and from second record onwards we have to take the amount from first record and so on.
I tried implementing with the help of stage variables but it didnot help.
Would appreciate if someone can provide some insight on the above logic.
Thanks
Vineet Singh
-
- Participant
- Posts: 21
- Joined: Mon Mar 16, 2009 3:59 am
-
- Participant
- Posts: 437
- Joined: Fri Oct 21, 2005 10:00 pm
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Participant
- Posts: 21
- Joined: Mon Mar 16, 2009 3:59 am
-
- Charter Member
- Posts: 822
- Joined: Sat Sep 17, 2005 5:25 pm
- Location: USA
Vineet,
It can all be done by using a stage variable to store the previous value and populate this vale in the current Column.
But why would anyone like to modify the Amounts associated with Products in such a fashion unless this is some kinda fix.
sAM
It can all be done by using a stage variable to store the previous value and populate this vale in the current Column.
But why would anyone like to modify the Amounts associated with Products in such a fashion unless this is some kinda fix.
sAM
I haven't failed, I've found 10,000 ways that don't work.
Thomas Alva Edison(1847-1931)
Thomas Alva Edison(1847-1931)
Just wanted to point out that simply saying you can do it doesn't help someone who doesn't know how to do it. Best to flesh out an answer like this with an actual example of how one would make that work...us1aslam1us wrote:It can all be done by using a stage variable to store the previous value and populate this vale in the current Column.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
Right click, stage variable properties, it will open a metadata table. In there you can also choose to set initial values.
Stage variables are executed once per row in top to bottom order. Here is some pseudo-code example of one way (run this in sequential mode after you have sorted according to your needs):
svAdjAmt set to: If @INROWNUM = 1 Then SetNull() Else svPreviousAdjAmt
svPreviousAdjAmt set to: lnk.AdjAmt
Depending on your version you may not be able to set a stage var to null; you could set it to 999999 or something else instead. Then drag the svAdjAmt down to your new AdjAmt column on the output link.
Stage variables are executed once per row in top to bottom order. Here is some pseudo-code example of one way (run this in sequential mode after you have sorted according to your needs):
svAdjAmt set to: If @INROWNUM = 1 Then SetNull() Else svPreviousAdjAmt
svPreviousAdjAmt set to: lnk.AdjAmt
Depending on your version you may not be able to set a stage var to null; you could set it to 999999 or something else instead. Then drag the svAdjAmt down to your new AdjAmt column on the output link.
Last edited by qt_ky on Wed Apr 25, 2012 3:57 pm, edited 1 time in total.
Choose a job you love, and you will never have to work a day in your life. - Confucius
-
- Participant
- Posts: 21
- Joined: Mon Mar 16, 2009 3:59 am
-
- Participant
- Posts: 21
- Joined: Mon Mar 16, 2009 3:59 am