Aggregation By row-wise

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
Prince_Hyd
Participant
Posts: 35
Joined: Mon May 06, 2013 5:59 am

Aggregation By row-wise

Post by Prince_Hyd »

Hello Folks

I have a scenario similar to this

Source Target

Dept,sal Count
10,100 100
10,110 210
20,200 200
20,210 410

How to perform this.

Thanks
prasson_ibm
Premium Member
Premium Member
Posts: 536
Joined: Thu Oct 11, 2007 1:48 am
Location: Bangalore

Post by prasson_ibm »

Hi,

Iit seems to be a interview question.
Please tell us that what you have attempted so far.
Prince_Hyd
Participant
Posts: 35
Joined: Mon May 06, 2013 5:59 am

Post by Prince_Hyd »

Hello Parsson

I took one stagevar for deptno and given logic like this

StageVar = deptno

If deptno = StageVar Then S1+Sal Else Sal --------------- S1

but i'm not getting the expected result


Thanks
asorrell
Posts: 1707
Joined: Fri Apr 04, 2003 2:00 pm
Location: Colleyville, Texas

Post by asorrell »

I believe what you need are two stage variables:

1) svCount = If (incominglink.Dept = svDept) Then (svCount + incominglink.Sal) Else incominglink.Sal
2) svDept = incominglink.Dept


They must be in that order. svDept should be initialized to "".
Last edited by asorrell on Wed Sep 04, 2013 1:16 pm, edited 1 time in total.
Andy Sorrell
Certified DataStage Consultant
IBM Analytics Champion 2009 - 2020
Prince_Hyd
Participant
Posts: 35
Joined: Mon May 06, 2013 5:59 am

Post by Prince_Hyd »

Hello Andy

Thanks for your solution, it worked perfectly!
Post Reply