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: 
rachelpurple
Partner - Contributor III
Partner - Contributor III

How to convert one column to two rows whilst other columns remain the same.

Hi,

My source table is like below:

HostCluster
1a
2a
3b
4b
5c
6c
7d
8d
9e
10e
11f
12f

but I want to make it flatter in qlikview, like below:

Host 1

Host 2Cluster
12a
34b
56c
78d
910e
1112f

How can I realise this in load script? or in straight table / pivot table?

1 Solution

Accepted Solutions
sunny_talwar

May be like this:

Table:

LOAD Host,

    Cluster,

    AutoNumber(Host, Cluster) as Key

FROM

[https://community.qlik.com/thread/220822]

(html, codepage is 1252, embedded labels, table is @1);

FinalTable:

LOAD Host as Host1,

  Cluster

Resident Table

Where Key = 1;

Join (FinalTable)

LOAD Host as Host2,

  Cluster

Resident Table

Where Key = 2;

DROP Table Table;


Capture.PNG

View solution in original post

6 Replies
sunny_talwar

May be like this:

Table:

LOAD Host,

    Cluster,

    AutoNumber(Host, Cluster) as Key

FROM

[https://community.qlik.com/thread/220822]

(html, codepage is 1252, embedded labels, table is @1);

FinalTable:

LOAD Host as Host1,

  Cluster

Resident Table

Where Key = 1;

Join (FinalTable)

LOAD Host as Host2,

  Cluster

Resident Table

Where Key = 2;

DROP Table Table;


Capture.PNG

srchilukoori
Specialist
Specialist

Hi,

Another option:

Original:

LOAD Host,

     Cluster

FROM

[https://community.qlik.com/thread/220822]

(html, codepage is 1252, embedded labels, table is @1);

Transformed:

LOAD Cluster,

     SubField(HostList, ',', 1) As Host1,

     SubField(HostList, ',', 2) As Host2;

LOAD Cluster,

     Concat(Host, ',', Host) As HostList

Resident Original

Group by Cluster;

DROP Table Original;

rachelpurple
Partner - Contributor III
Partner - Contributor III
Author

it works!

Thanks very much !

nizamsha
Specialist II
Specialist II

TableA:

LOAD * ,Odd(ID) as Host1,

Even(ID) as Host2;

Load * Inline [

ID,Name

1,1

2,1

];

NoConcatenate

Load ID as Host3,Name Resident TableA Where Host1='-1';

Load ID as Host4,Name Resident TableA Where Host2='-1';

DROP Table  TableA;

exit SCRIPT;

er_mohit
Master II
Master II

Hi, Try this

Table:

LOAD// Host,

    Cluster,

    FirstValue(Host) as Host1,

    LastValue(Host) as Host2

FROM

[https://community.qlik.com/thread/220822]

(html, codepage is 1252, embedded labels, table is @1)Group by Cluster;

sunny_talwar

Awesome

Please close the thread if you got what you wanted by marking correct and helpful responses.

Qlik Community Tip: Marking Replies as Correct or Helpful

Best,

Sunny