Row count with transformer.

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
kennyapril
Participant
Posts: 248
Joined: Fri Jul 30, 2010 9:04 am

Row count with transformer.

Post by kennyapril »

I have a field customerInfoID which has duplicates like 101,101,101,101,102,102,102.
The output I need is 101,4 and 102,3 i.e row count of each customerInfoID.

This can be done through aggregator but I wanted to do this in transformer to avoid using aggregator

please suggest me the function which has to be used



Thanks
Regards,
Kenny
vinothkumar
Participant
Posts: 342
Joined: Tue Nov 04, 2008 10:38 am
Location: Chennai, India

Post by vinothkumar »

I think there are no specific functions to do this in transformer. You have to use StageVariables along with transformer.
kennyapril
Participant
Posts: 248
Joined: Fri Jul 30, 2010 9:04 am

Post by kennyapril »

In the stage variable do I need to find the count of Rows or how can I do it?


Thanks
Regards,
Kenny
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

It's basic 'group change detection'. You increment a stage variable each time you see the same 'group'. For a new group, you set the count back to 1.

Leveraging the Sort stage with a 'Key Change Column' will simplify this for you.
-craig

"You can never have too many knives" -- Logan Nine Fingers
vinothkumar
Participant
Posts: 342
Joined: Tue Nov 04, 2008 10:38 am
Location: Chennai, India

Post by vinothkumar »

Use remove duplicates stage and keep the last one.
kennyapril
Participant
Posts: 248
Joined: Fri Jul 30, 2010 9:04 am

Post by kennyapril »

That works!!

Thankyou All
Regards,
Kenny
Post Reply