Page 1 of 1

horizontal pivoting using transformer

Posted: Mon Apr 07, 2014 4:03 am
by HemaV
Hi All,

Needed a logic in transformer for the below scenario. i shouldn't use pivot stage. and needed in datastage and not using unix.

I/P data:
Account_numb Name Total
123 ABCDEF 123456789
345 GHIJKLMN 987654321

O/P data:
Account_numb Name Total
123 AB 123
123 CD 456
123 EF 789
345 GH 987
345 IJ 654
345 KL 321
345 MN NULL

Thanks in Advance,

Posted: Mon Apr 07, 2014 4:34 am
by dsetlteam
Try using loop variables (if you are on 8.5 or above version of datastage) in the transformer stage to get the required output

Re: horizontal pivoting using transformer

Posted: Mon Apr 07, 2014 4:36 am
by Poovalingam
You could try looping option in transformer stage to convert every single row to multiple rows based on our requirement.

You could use @ITERATION <= 3 as looping condition.

Thanks
Poovlaingam.

Posted: Mon Apr 07, 2014 4:39 am
by HemaV
Is there any logic without @Iteration and looping functions. can we implement using stage variables?

Thanks

Posted: Mon Apr 07, 2014 4:57 am
by ray.wurlod
What have YOU tried?

Posted: Mon Apr 07, 2014 4:50 pm
by chulett
What are your Business Requirements? Specifically wondering about the rules for the "Name" and "Total" field chopping up you seem to be doing but that's always a hard call to make when someone posts completely made up "example" data with no requirements. Right now it doesn't make all that much sense - every two characters from Name match up to three characters of Total? :?

And as asked before, what have you tried so far? What issues are you facing?

Posted: Tue Apr 08, 2014 2:00 am
by HemaV
i'm not sure on approach. trying to see anything can be done

Reply

Posted: Tue Apr 08, 2014 2:32 am
by ssnegi
Put three constraint links in transformer for 123,456,789...Then funnel them into one link with three records.

Re: Reply

Posted: Tue Apr 08, 2014 7:28 am
by chulett
ssnegi wrote:Put three constraint links in transformer for 123,456,789...Then funnel them into one link with three records.
Why 3? I don't see anything that notes it will always / only be three, matter of fact the second set of data shows 4 occurrences.

Posted: Tue Apr 08, 2014 7:32 am
by chulett
HemaV wrote:i'm not sure on approach. trying to see anything can be done
Fine. Again - what are your Business Requirements / transformation rules? Explain in words how to perform the splitting of the two columns so that people can stop guessing what you need done.

Reply

Posted: Tue Apr 08, 2014 4:16 pm
by ssnegi
You have to divide the data based on constraints. These should be as many as the maximum number of divisions. So if there are 4 maximum rows then 4 constraints. Then funnel these constraint links to collect them into rows.

Posted: Wed Apr 09, 2014 8:25 am
by bhasds
Hi HemaV,

The scenario can be solved by using loop variable.

In iteration-

@ITERATION <= Len(Reference.col2) /2

Take 2 loop variables-
Derivation LoopVariable
If @ITERATION <=1 Then LV1 Else LV1 +2 LV1(initialize with 2)

If @ITERATION <=1 Then LV2 Else LV2 +3 LV2(initialize with 3)

Output Derivation-

Derivation ColName

Col1 Col1
Right(Left(Reference.col2, LV1),2) Col2
If len(StripWhiteSpace(Right(Left(Reference.col3, LV2),3))) <3 Then "" Else Right(Left(Reference.col3, LV2),3) Col3


Regards
Bhasds

Posted: Wed Apr 09, 2014 8:28 am
by chulett
... or we could just continue to guess based on the wonderful example data.

Posted: Wed Apr 09, 2014 8:50 am
by thompsonp
chulett wrote:... or we could just continue to guess based on the wonderful example data.
Sounds fun. How many guesses are we allowed? Is there a prize? :wink:

Posted: Wed Apr 09, 2014 9:44 am
by chulett
Oh yes... a very special prize. <wink,wink>