Page 1 of 1

Pivot & Filter - Alternative option

Posted: Wed Jan 31, 2007 6:49 pm
by vijayrc
Friends,
I have a scenario like this...The input to Transformer is a record which has 4 occurences of a particular set of fields..
e.g, Input
Common Field1;Common Field2;Common Filed3; FieldA;FieldB;FieldA_1;FieldB_1;FieldA_2;FieldB_2;FieldA_3;FieldB_3
Output:
Common Field1;Common Field2;Common Filed3; FieldA;FieldB
Common Field1;Common Field2;Common Filed3; FieldA-1;FieldB-1
Common Field1;Common Field2;Common Filed3; FieldA-2;FieldB-2
Common Field1;Common Field2;Common Filed3; FieldA-3;FieldB-3

Transformer==>Pivot==>Filter [to filter any of the occurence when FieldA_* is zero]
Is there an alternative to get rid of this filter stage and yet get the task accomplished?
Thanks
Vijay

Posted: Wed Jan 31, 2007 6:55 pm
by DSguru2B
Probably another transformer after the pivot stage to constraint the output maybe :roll:

Posted: Wed Jan 31, 2007 11:02 pm
by ray.wurlod
Don't pass such rows through the first Transformer. Add the four checks to the output link constraint expression, conjoined with AND operators.

Posted: Thu Feb 01, 2007 7:43 am
by DSguru2B
Constraint and then pivot. This way you dont need an extra stage. Why didnt I think of that. Probably I was too tired.

Posted: Thu Feb 01, 2007 4:35 pm
by ray.wurlod
Too rushed, grasshopper.

Take the time to smell the flowers.

Meditate for a while. Ponder the questions.

:idea:

Posted: Thu Feb 01, 2007 6:08 pm
by DSguru2B
Your right, I need to slow down. Probably still a kid in datastage :roll:

Posted: Thu Feb 01, 2007 6:49 pm
by vijayrc
ray.wurlod wrote:Don't pass such rows through the first Transformer. Add the four checks to the output link constraint expression, conjoined with AND operators. ...
Ray
I'm not clear on this. Did you mean to have the four checks on the output constraint of the pivot ?!?!?! or do you mean to have an output link constraint expression on the first transformer to the pivot to be [if FieldA >0 AND FieldA_2 >0 AND FieldA_3>0 AND FieldA_4 > 0]
Anyhow I need the first transformer to do other stuffs besides passing some rows to the pivot.

Posted: Thu Feb 01, 2007 6:51 pm
by DSguru2B
No, Constraint it in the first transformer itself. You cannot do it in the pivot stage.

Posted: Thu Feb 01, 2007 8:16 pm
by ray.wurlod
Yes, I meant in the first Transformer stage. And it's perfectly OK that this stage does "other stuff". All my suggestion adds is an additional condition on the output constraint expression - it does not affect anything else you are doing with this Transformer stage.

Posted: Fri Feb 02, 2007 9:49 am
by vijayrc
ray.wurlod wrote:Yes, I meant in the first Transformer stage. And it's perfectly OK that this stage does "other stuff". All my suggestion adds is an additional condition on the output constraint expression - it does ...
Thanks..I'm not getting a way to work out..If you can get me the expression with my above example, may be that would help.

Posted: Fri Feb 02, 2007 3:15 pm
by ray.wurlod

Code: Select all

FieldA <> 0 And FieldA_1 <> 0 And FieldA_2 <> 0 And FieldA_3 <> 0
And any other constraint that you may already have.

Posted: Sat Feb 03, 2007 1:42 pm
by vijayrc
ray.wurlod wrote:

Code: Select all

FieldA <> 0 And FieldA_1 <> 0 And FieldA_2 <> 0 And FieldA_3 <> 0
And any other constraint that you may already have. ...
Ray, by doing this, Only if all the four fields [FieldA,FieldA_2,Field_3,Field_4 are non-zeros] then the constraint gets satisfield.
My requirement is if FieldA is 0, FieldA,FieldB shouldn't be written out,
If FieldA_2 > 0, FieldA_2,FieldB_2 should be writtenout and
If FieldA_3 > 0, FieldA_3,FieldB_3 should be writtenout and
If FieldA_3 = 0, FieldA_4,FieldB_4 shouldn't be writtenout

Posted: Sat Feb 03, 2007 2:41 pm
by ray.wurlod
You did not make that clear till now.
Your only solution will require four separate output links, separately constrained, since they will have different metadata.