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: 
Koen_D
Contributor III
Contributor III

Transforming table

Hi Qlik experts,

I have a table that looks like this:

Example:

LOAD * INLINE [

ID, Value, Flag1, Flag2, Flag3

1, 5, Yes, Yes, No

2, 5, Yes, No, No

3, 10, No, No, Yes

4, 20, Yes, Yes, Yes

]; 

I want to transform this data to look like this:

Result:

LOAD * INLINE [

ID, Value, Flag

1, 5, Flag1

1, 5, Flag2

2, 5, Flag1

3, 10, Flag3

4, 20, Flag1

4, 20, Flag2

4, 20, Flag3

]; 

So I want to pivot the last three flag columns to form a new column that has the value of the name of the column. 

Labels (4)
1 Solution

Accepted Solutions
Clement15
Partner - Specialist
Partner - Specialist

Hello, this should answer your problem.

 

TEST:
LOAD * INLINE [
 
ID, Value, Flag1, Flag2, Flag3
 
1, 5, Yes, Yes, No
 
2, 5, Yes, No, No
 
3, 10, No, No, Yes
 
4, 20, Yes, Yes, Yes
 
]; 
 
 
 
TEST2:
CrossTable(Flag,Temp, 2)
Load
ID,
    Value,
    Flag1,
    Flag2,
    Flag3
Resident TEST;
 
TEST3:
Load
ID,
Value,
Flag
Resident TEST2
where Temp = 'Yes';
 
drop table TEST,TEST2;

View solution in original post

1 Reply
Clement15
Partner - Specialist
Partner - Specialist

Hello, this should answer your problem.

 

TEST:
LOAD * INLINE [
 
ID, Value, Flag1, Flag2, Flag3
 
1, 5, Yes, Yes, No
 
2, 5, Yes, No, No
 
3, 10, No, No, Yes
 
4, 20, Yes, Yes, Yes
 
]; 
 
 
 
TEST2:
CrossTable(Flag,Temp, 2)
Load
ID,
    Value,
    Flag1,
    Flag2,
    Flag3
Resident TEST;
 
TEST3:
Load
ID,
Value,
Flag
Resident TEST2
where Temp = 'Yes';
 
drop table TEST,TEST2;