Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
dthornburg
Contributor II
Contributor II

Converting Vertical Table to Horizontal Table

Hi,

I need to convert this table into a horizontal table. Tried cross table but I receive an error that "Field names must be unique for a table. How can this be accomplished. Tried Generic load also but that is not working either.

Horizon:
LOAD
BatchID AS BatchID_Horiz,
Name AS Name_Horiz,
Answer AS Answer_Horiz
FROM [lib://Perryman_Summary_Data/00_QVD/Horizon.qvd]
(qvd);

Horizon2:
CrossTable(BatchID_Horiz,Name_Horiz,2)
Load *
Resident Horizon;

 

// Generic Load
// BatchID AS BatchID_Horiz,
// 'part'&"Name AS AS Name_Horiz,
// Answer AS Answer_Horiz
// Resident Horizon;

// Drop table Horizon;

 

The goal is to get 1 row for each batch ID. The column headings would be the value in the current "Name" column and the result for the column is the Answer.

 

Sample DataSample Data

Labels (1)
1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I think Generic load like this would work,

Horizon:
Generic LOAD
BatchID AS BatchID_Horiz,
Name,
Answer
FROM [lib://Perryman_Summary_Data/00_QVD/Horizon.qvd]
(qvd);

What issue did you have with using Generic load?

-Rob

View solution in original post

3 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I think Generic load like this would work,

Horizon:
Generic LOAD
BatchID AS BatchID_Horiz,
Name,
Answer
FROM [lib://Perryman_Summary_Data/00_QVD/Horizon.qvd]
(qvd);

What issue did you have with using Generic load?

-Rob

Or
MVP
MVP

Do you specifically need to do this in your script? On the front end, this is as simple as creating a pivot with BatchID as the dimension, Name as the Column, and Only(Answer) as the measure, so if you don't specifically need it in script I'd recommend doing that.

If you specifically need it done in script, have a look at previous answers to the same question, e.g.

https://community.qlik.com/t5/App-Development/how-to-pivot-in-load-script/td-p/1513761

 

dthornburg
Contributor II
Contributor II
Author

Thank You the Generic Load worked. I wanted to convert this to a  horizontal table to make every column searchable. End users have no idea what the Back ID is and want o search by the row names.