Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Transpose columns into rows

Hello,

I have this tMap output and I would like to transpose these four columns into rows.

 

0683p000009M6TE.png

 

I want the new output to be this:

 

0683p000009M6TJ.png

 

Could someone help me?

 

Thank you!

 

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi,

 

You can convert the columns into rows using tUnpivotRows. But I am not able to find this component in the Talend latest version.

I have solved the query with own logic you can also try from your end.

The whole logic is:-

0683p000009M65p.png

Before triggering the job no. of fields and rows should be known. In your case field is 4 and rows no. is 3. Set these value into context. In tJavaRow multiply both context to find total no. of line.

 

0683p000009M6QC.png 

In the first tMap add all the columns to create a single column (VALID_INVALID) separated by ","

 

0683p000009M6Td.png

 

Then use tNormalize to create no. of rows which are separated by a comma.

In the second tMap use sequence generator to create no.  of line and put in a variable. And use the variable to assign column(DQ_RULE).

Condition is:-

Mathematical.MOD(Var.var1,context.field)==1?"DQ_COMP_PROD"0683p000009MPcz.pngMathematical.MOD(Var.var1,context.field)==2?"DQ_FORM_PROD"0683p000009MPcz.pngMathematical.MOD(Var.var1,context.field)==3?"DQ_COMP_CODPROVEEDOR":"DQ_FORM_CODPROVEEDOR"))  

 

0683p000009M6IU.png

 

Add tSorterRow to sort the column(DQ_RULE). And you will get the desired output.

0683p000009M6Ti.png

 

If your query is answered, please mark the topic as resolved.

Thanks

View solution in original post

1 Reply
Anonymous
Not applicable
Author

Hi,

 

You can convert the columns into rows using tUnpivotRows. But I am not able to find this component in the Talend latest version.

I have solved the query with own logic you can also try from your end.

The whole logic is:-

0683p000009M65p.png

Before triggering the job no. of fields and rows should be known. In your case field is 4 and rows no. is 3. Set these value into context. In tJavaRow multiply both context to find total no. of line.

 

0683p000009M6QC.png 

In the first tMap add all the columns to create a single column (VALID_INVALID) separated by ","

 

0683p000009M6Td.png

 

Then use tNormalize to create no. of rows which are separated by a comma.

In the second tMap use sequence generator to create no.  of line and put in a variable. And use the variable to assign column(DQ_RULE).

Condition is:-

Mathematical.MOD(Var.var1,context.field)==1?"DQ_COMP_PROD"0683p000009MPcz.pngMathematical.MOD(Var.var1,context.field)==2?"DQ_FORM_PROD"0683p000009MPcz.pngMathematical.MOD(Var.var1,context.field)==3?"DQ_COMP_CODPROVEEDOR":"DQ_FORM_CODPROVEEDOR"))  

 

0683p000009M6IU.png

 

Add tSorterRow to sort the column(DQ_RULE). And you will get the desired output.

0683p000009M6Ti.png

 

If your query is answered, please mark the topic as resolved.

Thanks