Use of aggregator stage to sum columns value

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
swapna07
Participant
Posts: 22
Joined: Fri Mar 08, 2013 11:29 am
Contact:

Use of aggregator stage to sum columns value

Post by swapna07 »

Hi All,

I have a scenario with sequential file as input data as below:
Name Sub1 Sub2 Sub3
abc 70 80 90
def 50 70 80
ghi 50 80 90

I need to sum the columns sub1+sub2+sub3 and get the value in new column 'Total' in output file as below:
Name Sub1 Sub2 Sub3 Total
abc 70 80 90 240

I tried using transformer but it was cubersome and could not do it, can anyone help how to achieve this using aggregator stage.

Thanks in advance.
thompsonp
Premium Member
Premium Member
Posts: 205
Joined: Tue Mar 01, 2005 8:41 am

Re: Use of aggregator stage to sum columns value

Post by thompsonp »

Please let us know what you put as the derivation for the new "Total" column in the transformer.
You are not aggregating rows, rather summing columns, so the aggregator is not going to help in this instance.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Not really sure how the transformer solution would be cumbersome. All you seem to be doing is putting a new column on the output link and adding up the other three. Yes? :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
swapna07
Participant
Posts: 22
Joined: Fri Mar 08, 2013 11:29 am
Contact:

Post by swapna07 »

I wanted to do that with aggregator, is it not possible?
With transformer I included 3 stage variable , but I was not sure how to use it
in the output link so as it sums up the Sub1 Sub2 and Sub3 values on Name key column. Please help!
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You don't need stage variables, just a simple derivation in the new column to add the other three together. And this is not something you can do in the Aggregator, it does sums across rows not within.
Last edited by chulett on Thu Jan 16, 2014 12:37 pm, edited 1 time in total.
-craig

"You can never have too many knives" -- Logan Nine Fingers
swapna07
Participant
Posts: 22
Joined: Fri Mar 08, 2013 11:29 am
Contact:

Post by swapna07 »

Alright Craig.Thanks for info, I will try that tomorrow once I go to office, and if I stuck up somewhere I will let you know. Hey btw do we have any way of having Datastage installed at our WAN/LAN home server ?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Only if you have a valid license.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply