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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
m_woolf
Master II
Master II

Transpose a simple table

I have this table with no headers:

a    1
b    2
c    3
d   4

I want it to look like this where a,b,c,d are now headers:

a   b  c  d
1   2  3  4

I think I should use Crosstable, but so far no joy.

Labels (1)
1 Solution

Accepted Solutions
neerajthakur
Creator III
Creator III

Refer to this example :

tmpData:
Crosstable (Designation, Values)
Load * inline [
City, L1, L2, L3, L4, L5, L6
Mumbai, 1, 0, 0, 1, 1, 0
Bangalore, 0, 0, 1, 1, 1, 0
Delhi, 1, 1, 0, 0, 0, 0
Pune, 1, 0, 0, 1, 1, 1
];

Generic
Final:
Load
Designation,
City as City2,
Values

Resident tmpData;

 

GenericTableJoin:
Load Distinct Designation Resident tmpData;

Drop Table tmpData;

FOR i = NoOfTables()-1 to 0 STEP -1;
LET vTable=TableName($(i));
IF WildMatch('$(vTable)','Final.*') THEN
LEFT JOIN ([GenericTableJoin]) LOAD * RESIDENT [$(vTable)];
DROP TABLE [$(vTable)];
ENDIF
NEXT i

 

Exit Script;

 

Thanks & Regards,
Please Accepts as Solution if it solves your query.

View solution in original post

1 Reply
neerajthakur
Creator III
Creator III

Refer to this example :

tmpData:
Crosstable (Designation, Values)
Load * inline [
City, L1, L2, L3, L4, L5, L6
Mumbai, 1, 0, 0, 1, 1, 0
Bangalore, 0, 0, 1, 1, 1, 0
Delhi, 1, 1, 0, 0, 0, 0
Pune, 1, 0, 0, 1, 1, 1
];

Generic
Final:
Load
Designation,
City as City2,
Values

Resident tmpData;

 

GenericTableJoin:
Load Distinct Designation Resident tmpData;

Drop Table tmpData;

FOR i = NoOfTables()-1 to 0 STEP -1;
LET vTable=TableName($(i));
IF WildMatch('$(vTable)','Final.*') THEN
LEFT JOIN ([GenericTableJoin]) LOAD * RESIDENT [$(vTable)];
DROP TABLE [$(vTable)];
ENDIF
NEXT i

 

Exit Script;

 

Thanks & Regards,
Please Accepts as Solution if it solves your query.