Handling Nulls in Aggregator

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
rajeevs
Participant
Posts: 14
Joined: Thu Jan 12, 2006 10:42 am

Handling Nulls in Aggregator

Post by rajeevs »

Hello All:

I have a quick question on using the Aggregator stage (Enterprise Edition).

I have an AMT column which is a nullable column and it passes through the Aggregator to determine the sum, based on a set of grouped key columns. When the AMT column is null at the source the data after aggregation shows 0.

Since 0 and Null's are different, i was wondering how to get NULL's at the Output.

Any Suggestions are welcome !!

Thanks All !!
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

NULLs are ignored when counting or averaging. The result of a SUM operation will always be a number, never a NULL.

You need to turn zeroes to NULL after aggregation. If your desire is to produce a NULL if all source column values where NULL, you'll have to check for that using a separate aggregation column to count the occurences of NULL.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
rajeevs
Participant
Posts: 14
Joined: Thu Jan 12, 2006 10:42 am

Post by rajeevs »

Thanks Ken !!

I actually did find a solution to the problem !! Within the Aggregator stage there is an option to All Null Output. This by default is set to NULL. When set to True works like a charm !!
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Hey, I just learned something too. There's a lot of little switches here and there, I call it the "Magic Mushroom" approach. The video game Mario Brothers had hidden stars and buttons and mushrooms that if you jumped your character in the right place, you would hit one of these and gain a special power or prize. You only knew where these were by jumping around everywhere to see if something was hidden. It's like that with PX, just click around and see what secret switch or option is available.

Sorry for not being more helpful.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Wow... Ken dropping a Mario reference. Who woulda thunk it? :wink:
-craig

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