Page 1 of 1

One row into multiple rows

Posted: Tue Dec 02, 2008 3:20 pm
by dsdevper
Hi,

Sorry.I dont know how to say..Here i am giving an example of my queastion.

Each columns which has a flag value of '1' or '0' should come as an individual row in the output.

Ex:Input(all feilds are char feilds)

col1 col2 col3 col4 col5 col6
-------------------------------
aa 1 1 1 0 1

bb 0 1 1 1 1

Output should be as(all fields are char)

col1 col2 col3 col4 col5 col6
--------------------------------
aa 1 0 0 0 0
aa 0 1 0 0 0
aa 0 0 1 0 0
aa 0 0 0 0 0
aa 0 0 0 0 1

bb 0 0 0 0 0
bb 0 1 0 0 0
bb 0 0 1 0 0
bb 0 0 0 1 0
bb 0 0 0 0 1


Please any help..

Thanks

Posted: Tue Dec 02, 2008 3:41 pm
by Mike
First thing that comes to mind, use a transformer stage with 5 output links and then funnel them together.

In the first output link, map input columns to col1 and col2, and map zero to the others.
In the second output link, map input columns to col1 and col3, and map zero to the others.

and so on ...

Mike

Posted: Tue Dec 02, 2008 4:38 pm
by eostic
Another way is to first use the pivot stage, pivoting on the five "occurrences" of your flag column....this will give you five rows for each "key" with the 1 or 0 .....then set up a counter for each of those keys that goes from 1 to 5, and then have five new columns in a follow up transformer.....each column will have a derivation that looks at the counter to determine if it should get a zero or the value of the (pivoted) flag.

Ernie

Posted: Wed Dec 03, 2008 9:10 am
by laknar
Hi,

Search with vertical pivot.