Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
berryandcherry6
Creator III
Creator III

convert rows to columns in qlik

Hi,

i have table like below

subject_access_idinteractivity_type_idvalueinteractivity_type
12341sentsent?
12342mailedmailed?
12343truestatus?
12351not sentsent?
12352mailedmailed?
12353falsestatus?
12361sentsent?

i want to display like below

subject_access_idsent?mailed?status?
1234sentmailedtrue
1235not sentmailedfalse
1236sent

how could i do this?

load subject_access_id, interactivity_type_id ,value, interactivity_type;

SQL SELECT `subject_access_id`,

    `interactivity_type_id`,

    value,

interactivity_type

FROM INTERACTIVITYDATA ;

13 Replies
berryandcherry6
Creator III
Creator III
Author

Hi sunny,

thanks it works!

one more question regarding this. If i don't have 'interactivity_type_id',

Table:

LOAD * INLINE [

    subject_access_id, value, interactivity_type

    1234,  sent, sent?

    1234, mailed, mailed?

    1234,  true, status?

    1235,  not sent, sent?

    1235, mailed, mailed?

    1235,  false, status?

    1236,  sent, sent?

];


At this time should i still use for loop to get the required output? if so how.

sunny_talwar

You can do this

Table:

LOAD * INLINE [

    subject_access_id, value, interactivity_type

    1234, sent, sent?

    1234, mailed, mailed?

    1234, true, status?

    1235, not sent, sent?

    1235, mailed, mailed?

    1235, false, status?

    1236, sent, sent?

];


FinalTable:

LOAD DISTINCT subject_access_id

Resident Table;



FOR i = 1 to FieldValueCount('interactivity_type')


LET vField = FieldValue('interactivity_type', $(i));

Left Join (FinalTable)

LOAD DISTINCT subject_access_id,

value as [$(vField)]

Resident Table

Where interactivity_type = '$(vField)';


NEXT


DROP Table Table;

harithad95156
Contributor III
Contributor III

Hi,

I have a week column where there are values like week2,week2.... So how to convert these field values into columns in qliksense straight table.

harithad95156
Contributor III
Contributor III

Hi Sunny,

I have a field name week with values week1,week2,week3...week5 and how to convert these values to columns in qliksense straight table?