Pivoting Problem
Posted: Fri May 16, 2008 3:43 pm
Hi,
I am trying to achive a vertical Pivot in a transformer. My Input looks like this Col1 is the Key column and Col2 is the value column
Col1 Col2
A 1
A 2
A 3
B 4
B 5
B 6
I am trying to get the Output as where '-' is Null
Col1 Col2 Col3 Col4
A 1 - -
A 1 2 -
A 1 2 3
B 4 - -
B 4 5 -
B 4 5 6
I have a sort stage with a Key change column and used the below with stage variables in transformer
svColId = If inlink.keyChange Then 1 Else svColId + 1
Row1 = If inlink.keyChange Then inlink.Col2 Else Row1
Row2 = If inlink.keyChange
Then SetNull()
Else If svColId=2
Then inlink.Col2
Else Row2
Row3 = If inlink.keyChange
Then SetNull()
Else If svColId=3
Then inlink.Col2
Else Row3
And so on
now the Problem----output is correct for the first Key but from the second key the stage variables store the old value and outputs the same
The output comes like this
Col1 Col2 Col3 Col4
A 1 - -
A 1 2 -
A 1 2 3
B 4 2 3
B 4 5 3
B 4 5 6
I HAVE DONE ENOUGH RESEARCH IN THE FORUM WITH 'VERTICAL PIVOT' BUT UNABLE TO FIND THE ANSWER---- Please help.
I am trying to achive a vertical Pivot in a transformer. My Input looks like this Col1 is the Key column and Col2 is the value column
Col1 Col2
A 1
A 2
A 3
B 4
B 5
B 6
I am trying to get the Output as where '-' is Null
Col1 Col2 Col3 Col4
A 1 - -
A 1 2 -
A 1 2 3
B 4 - -
B 4 5 -
B 4 5 6
I have a sort stage with a Key change column and used the below with stage variables in transformer
svColId = If inlink.keyChange Then 1 Else svColId + 1
Row1 = If inlink.keyChange Then inlink.Col2 Else Row1
Row2 = If inlink.keyChange
Then SetNull()
Else If svColId=2
Then inlink.Col2
Else Row2
Row3 = If inlink.keyChange
Then SetNull()
Else If svColId=3
Then inlink.Col2
Else Row3
And so on
now the Problem----output is correct for the first Key but from the second key the stage variables store the old value and outputs the same
The output comes like this
Col1 Col2 Col3 Col4
A 1 - -
A 1 2 -
A 1 2 3
B 4 2 3
B 4 5 3
B 4 5 6
I HAVE DONE ENOUGH RESEARCH IN THE FORUM WITH 'VERTICAL PIVOT' BUT UNABLE TO FIND THE ANSWER---- Please help.