Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Convert Column's Value to Row

Hi there,

 

I am looking for a way to convert column's value to row value. 

 

This is an input sample.

(In the actual case, I have these data inside a database)

0683p000009M9lD.pnginput

And this is the expected output.

I wanted to move the value from repeating column(w/ difference seq no.) to the corresponding column. 

 

0683p000009M9lI.pngexpected out

I heard about tUnpivotRow component, but I'm using Talend Cloud Studio (v 7.3), but I couldn't find pivot component.

 

Can anyone show me the JobDesign(screenshot) for achieving the expected output?

 

Here is the two method I tried.

 

1) Using tUnpivot

 

Job Design and Result

0683p000009M9em.pngunpivot -- job design and result             vs          0683p000009M9lI.pngexpected out          

Here, there are a few problems...

1) the column header (id, key1, value1) becomes a part of a row value....

2) the repeating column header (key2, value2, key3 ....) is still there

3) 

 

 

1.1 DBInput Schema

0683p000009M9lN.pngunpivot -- dbInput's schema

1.2 tUnpivotRow's Schema

0683p000009M9ZE.pngunpivot -- tUnpivotRow's Schema

 

1.3 tMap

0683p000009M9lS.pngunpivot -- tMap

 

2) tNormalize

 

Job Design and Result

0683p000009M9WK.pngnormalize -- job design and result

Here, there are few problems

1) 'key' and 'value' is not separated into a different column

2) manual mapping is needed == inflexible

3) id's auto increment is not working....

 

1.1 DBInput's Schema

0683p000009M9lX.pngnormalize-- dbInput's schema

1.2 tMap

0683p000009M9ch.pngnormalize -- tMap

 

1.3 tNormalize's Schema

0683p000009M9aV.pngnormalize -- tNormalize's Schema

 

Thank you

Labels (4)
1 Solution

Accepted Solutions
manodwhb
Champion II
Champion II

You can mark as slove this case also so that it will help to others.

View solution in original post

11 Replies
manodwhb
Champion II
Champion II

Use tunpivot component which you need to download from Talend exchange.
Anonymous
Not applicable
Author

@manodwhb 

I downloaded tUnpivot component from Talend exchange and tried to install the component, but nothing shows up in the palette.

*I am using Talend Cloud Studio v.7.3, but in the component detail page, it stated the compatibility to be up to v6.2...

Was this a compatibility problem??

 

I did restart once, but still the component doesn't show up.

 

0683p000009M9jr.png

Preference>Talend>Components

0683p000009M9VH.png

 

manodwhb
Champion II
Champion II

I have used in 7.1.1 ,which is working.
Anonymous
Not applicable
Author

is there a way to achieve this without tUnpivot component ??
manodwhb
Champion II
Champion II

You can try to create a file using tmap and then read it and pupulate.
In your tmap you should create below way.

row1.col+","+row1.col2+"/n"+row.col+","+row1.col3
Anonymous
Not applicable
Author

@manodwhb 

So you mean using tMap?? Do I need tSplitRow or any other components?

Can you show me the screenshot of the job design?

 

I have tried a similar way before but it didn't work.

Can you help me improve this?

 

0683p000009M9q3.png

 

For you reference this is my input.

 

0683p000009M9lD.pnginput

and this is my expected output.

 

0683p000009M9lI.pngexpected out

 

Thanks

Anonymous
Not applicable
Author

@manodwhb 

I saw tUnpivotRow in the palette so I tried using it here.

 

Here is the two method I tried.  But neither works well...

 

1) Using tUnpivot

 

Job Design and Result

0683p000009M9em.pngunpivot -- job design and result             vs          0683p000009M9lI.pngexpected out          

Here, there are a few problems...

1) the column header (id, key1, value1) becomes a part of a row value....

2) the repeating column header (key2, value2, key3 ....) is still there

3) 

 

 

1.1 DBInput Schema

0683p000009M9lN.pngunpivot -- dbInput's schema

1.2 tUnpivotRow's Schema

0683p000009M9ZE.pngunpivot -- tUnpivotRow's Schema

 

1.3 tMap

0683p000009M9lS.pngunpivot -- tMap

 

2) tNormalize

 

Job Design and Result

0683p000009M9WK.pngnormalize -- job design and result

Here, there are few problems

1) 'key' and 'value' is not separated into a different column

2) manual mapping is needed == inflexible

3) id's auto increment is not working....

 

1.1 DBInput's Schema

0683p000009M9lX.pngnormalize-- dbInput's schema

1.2 tMap

0683p000009M9ch.pngnormalize -- tMap

 

1.3 tNormalize's Schema

0683p000009M9aV.pngnormalize -- tNormalize's Schema

 

manodwhb
Champion II
Champion II

In tunpivot you need to specify the ID column as row key section.
Anonymous
Not applicable
Author

@manodwhb 

Here I specified the ID column as key0683p000009M9q8.pngtUnpivot's Component

 

Here's the run result,,, 

0683p000009M9qD.pngtUnpivotRow's Actual Result

however the column name only becomes a row value

I wanted to move the value 'k2'~'k7' and 'v2'~'v7' under the column 'key1' and 'value1' respectively

and remove the other columns (eg. value2, key2 ...)

 

Expected Result

0683p000009M9qI.pngExpected Output

I feel that additional mapping might be needed but I'm not sure how I could do that.

 

For you reference, I modified the row value a bit here to avoid confusion

Input

0683p000009M9qN.pngInput