Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have this tMap output and I would like to transpose these four columns into rows.
I want the new output to be this:
Could someone help me?
Thank you!
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:-
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.
In the first tMap add all the columns to create a single column (VALID_INVALID) separated by ","
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"Mathematical.MOD(Var.var1,context.field)==2?"DQ_FORM_PROD"
Mathematical.MOD(Var.var1,context.field)==3?"DQ_COMP_CODPROVEEDOR":"DQ_FORM_CODPROVEEDOR"))
Add tSorterRow to sort the column(DQ_RULE). And you will get the desired output.
If your query is answered, please mark the topic as resolved.
Thanks
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:-
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.
In the first tMap add all the columns to create a single column (VALID_INVALID) separated by ","
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"Mathematical.MOD(Var.var1,context.field)==2?"DQ_FORM_PROD"
Mathematical.MOD(Var.var1,context.field)==3?"DQ_COMP_CODPROVEEDOR":"DQ_FORM_CODPROVEEDOR"))
Add tSorterRow to sort the column(DQ_RULE). And you will get the desired output.
If your query is answered, please mark the topic as resolved.
Thanks