Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

script columns to column

Hi All,

How can i do the following in the script:

Input:

Data | Group1 | Group2 | Group3

1          A               B          C

2          A               D          C

Output:

Data | Group

1          A

1          B

1          C

2          A

2          D   

2          C

Thanks in advance.

1 Solution

Accepted Solutions
simondachstr
Valued Contributor III

Re: script columns to column

Input:

LOAD * Inline [
Data , Group1 , Group2 , Group3
1, A, B, C
2, A, D, C
]
;

Final:
Crosstable(Data1, Group,1)
LOAD
Data,
Group1,
Group2,
Group3
Resident Input;

Drop fields Data1 from Final;

Drop Tables Input;


5 Replies
simondachstr
Valued Contributor III

Re: script column field to one column

Use the CrossTable function preceding your LOAD statement in your script, e.g.

Crosstable(Data, Group,1)

LOAD

     Data,

     Group1,

     Group2,

     Group3

Resident Input;

Re: script columns to column

This is the code:

let me know

Input:
LOAD * Inline [
Data , Group1 , Group2 , Group3
1, A, B, C
2, A, D, C
]
;

MyTable1:
NoConcatenate
LOAD Data Resident Input;
Left Join
LOAD Data, Group1 as Group Resident Input;

MyTable2:
NoConcatenate
LOAD Data Resident Input;
Left Join
LOAD Data, Group2 as Group Resident Input;

MyTable3:
NoConcatenate
LOAD Data Resident Input;
Left Join
LOAD Data, Group3 as Group Resident Input;

DROP Table Input;

MyTable:
NoConcatenate
LOAD * Resident MyTable1;
Concatenate
LOAD * Resident MyTable2;
Concatenate
LOAD * Resident MyTable3;

DROP Tables MyTable1, MyTable2, MyTable3;

simondachstr
Valued Contributor III

Re: script columns to column

Input:

LOAD * Inline [
Data , Group1 , Group2 , Group3
1, A, B, C
2, A, D, C
]
;

Final:
Crosstable(Data1, Group,1)
LOAD
Data,
Group1,
Group2,
Group3
Resident Input;

Drop fields Data1 from Final;

Drop Tables Input;


Re: script columns to column

Crosstable is the best Solution I know but my example is a useful exercise to manage tables!

Re: script columns to column

Hi,

One more solution

TEMP:
LOAD * INLINE [
Data, Group1, Group2, Group3
1, A, B, C
2, A, D, C
]
;

FINAL:
LOAD Data,
Group1 as Group
Resident TEMP;


join
LOAD Data,
Group2 as Group
Resident TEMP;

join
LOAD Data,
Group3 as Group
Resident TEMP;

DROP table TEMP;

Regards

Regards,
Prashant Sangle
Community Browser