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

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to convert rows into columns ?

Hi,
I have an input XML file.
I would like to obtain the following result :
id | picture1 | picture2 | picture3
1 | 7355448.jpg | 7893544.jpg | 2364758.jpg
2 | 1234567.jpg | 7864125.jpg | 1478523.jpg
3 | 7391845.jpg | 7319846.jpg | 7829657.jpg
...
For one id, i can have one or several pictures.
In the output Excel, I would like to obtain only the first three pictures.
When I realize the mapping, I get the following result :
id | picture1
1| 7355448.jpg
1| 7893544.jpg
1| 2364758.jpg
1| 7365599.jpg
1| 7733548.jpg
2| 1234567.jpg
2| 7864125.jpg
2| 1478523.jpg
2| 1122778.jpg
2| 9977443.jpg
...
Can I do that with TOS ? How to solve the problem ?
Regards.
Labels (3)
26 Replies
Anonymous
Not applicable
Author

may not be optimized but I have a small hint...
- Read xml file
- Merge three columns into Picture1 with separator as "|" using tMap/javarow and string concatenations
- Use tNormalize for Picture1 column
- Use tJavaRow - create new column as rowcnt - Identify row count where id is 1
- use filter component to filter out where rowcnt > 3
Vaibhav
Anonymous
Not applicable
Author

Hi SPITman,
It could be possible with TOS but the output you expected is not clear.
I got the output in trasnposed format with the input file as you mentioned.
i have used 3 outputs in tmap and applied inner join between keys for each picture type(1,2,3).
output:
.--+-----------.
| tLogRow_1 |
|=-+----------=|
|id|picture1 |
|=-+----------=|
|1 |7355448.jpg|
|1 |7893544.jpg|
|1 |2364758.jpg|
|2 |1234567.jpg|
|2 |7864125.jpg|
|2 |1478523.jpg|
|3 |7391845.jpg|
|3 |7319846.jpg|
|3 |7829657.jpg|
'--+-----------'
Thanks,
Bhanu.
Anonymous
Not applicable
Author

Hi,
In fact, I would like to obtain the following result :
id | picture1 | picture2 | picture3
1 | 7355448.jpg | 7893544.jpg | 2364758.jpg
2 | 1234567.jpg | 7864125.jpg | 1478523.jpg
3 | 7391845.jpg | 7319846.jpg | 7829657.jpg

In the input XML file, I can have several pictures (25 for instance) for one id.
In the output Excel, I would like to obtain only the first three pictures (COLUMNS and not ROWS)
Anonymous
Not applicable
Author

Hi,
I think you don't understand me...

I would like to obtain the following result :
id | picture1 | picture2 | picture3
1 | 7355448.jpg | 7893544.jpg | 2364758.jpg
2 | 1234567.jpg | 7864125.jpg | 1478523.jpg
3 | 7391845.jpg | 7319846.jpg | 7829657.jpg

In the input XML file, I can have several pictures (25 for instance) for one id.
In the output Excel, I would like to obtain only the first three pictures (in COLUMNS and not ROWS)
That's all
Anonymous
Not applicable
Author

Hi,
I hope tSplitRow will solve the your issue.
Stick with this URL: http://www.vikramtakkar.com/2013/09/tra ? split.html
Thanks,
kumar
Anonymous
Not applicable
Author

Hi,
tSplitrow splits a row into several rows. I search to split rows into several columns.
Anonymous
Not applicable
Author

I have created a sample job and tested, please check whether it is as expected or not.
0683p000009MDlD.png 0683p000009MECl.png 0683p000009MECq.png 0683p000009ME8L.png
Anonymous
Not applicable
Author

Thanks for your reply.
I check it now !
Anonymous
Not applicable
Author

if you want to obtain first three images then you have to used tDenormalizeSortedRow component instead tDenormalize. rest of the things remain same.