Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Group Wise Incremental Calculation

Status
Not open for further replies.

srvu

Programmer
Apr 29, 2008
49
US
Source

No Al_No Amt
X1 1 20
X1 2 30
X1 3 40
X1 4 50
X2 1 60
X2 2 20

I have a source as above

Data that shud be populated in Target

No Al_No Amt Prev_buffer_Amt
X1 1 20 0 (shud be)
X1 2 30 20
X1 3 40 50 (sum of prev amts (20+ 30))
X1 4 50 90 (group wise calculations (20+30+40))
X2 1 60 0
X2 2 20 60

Data in Column Prev_buffer_amt shud be the Prev records sum amt (group by NO). For 1st records Prev_amt will be Zero.For 2nd record Prev_amt shud be the 1st record amt,
For 3rd record, sum of (1st and 2nd records amts)......

Can it be calculated in Expression Transformation?

kindly help....



 
I got answer from the post given by MacLeod72 on running totals..
Port 1: KEY Input
Port 2: VAL Input
Port 3: V_TOTAL Variable Exp: IIF(KEY != V_KEY, VAL, V_TOTAL + VAL)
Port 4: V_KEY Variable Exp: KEY
Port 5: RUNNING_TOTAL Output Exp: V_TOTAL

Thanks to MacLeod72
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top