Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
vladimirkup
Contributor III
Contributor III

Rotate table

Hello, 

I have a following simple table:

Months|Sales|Profit

Jan         | 1M    | 100K

Feb        | 2M     | 200K

March  | 3M     | 300K

How can rotate it in QLIK Sense that at the end it will look like this:

               Jan  | Feb |March

Sales    1M  |  2M   |  3M

Profit   100 | 200K |300K

Thanks in Advance

 

2 Solutions

Accepted Solutions
Taoufiq_Zarra

OK

attahced, a  new way :

Data:

LOAD * INLINE [
Months, Sales, Profit
Jan, 1M , 100K
Feb ,2M , 200K
March , 3M     , 300K
];


let NumRows=NoOfRows('Data');
Let vcount =NoOfFields('Data');
FOR i=0 to $(NumRows)-1
	For j=2 to $(vcount)

 		 LET Value=Peek(FieldName($(j),'Data'),$(i),'Data');
 		 let title=Peek(FieldName(1,'Data'),$(i),'Data');
 		  let title2=FieldName($(j),'Data');

 load 
'$(title2)' AS Title,
 '$(Value)' as '$(title)'
 autogenerate(1);

NEXT;
NEXT;

drop table Data;

 

 

Capture.PNG

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉

View solution in original post

Aspiring_Developer
Specialist
Specialist

Hi @Taoufiq_Zarra 

I have a similar set of query , could you please help me with the below scenario :-

UserID UserNumber Feedback YN Question
29 11111111 YES Q1) Did you completed the day one activities ?
30 11111111 YES Q2)Did you share the infomration with customer ?
31 11111111 N/A Q3) Did you escalate if required ?
32 11111111 YES Q4Did you follow the closure process ?

 

And I wish to achieve the below output :-

UserID User Number Q1) Did you completed the day one activities ? Q2)Did you share the information with customer ? Q3) Did you escalate if required ? Q4) Did you follow the closure process ?
29 11111111 YES      
30 11111111   YES    
31       N/A  
32         Yes

 

I tried your solution but I could not able to do it correctly with my data as I need the other fields as well. Could you please help me with this ?

I cannot use the generic load solution here as it results in creation of multiple tables and synthetic keys .

Thanks

 

View solution in original post

5 Replies
Taoufiq_Zarra

attached

LOAD
    *
FROM [lib://Downloads/test1683696.xlsx]
(ooxml, embedded labels, table is Feuil2, filters(
Rotate(right)
));

 

Capture.PNG

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
vladimirkup
Contributor III
Contributor III
Author

Thanks !

i load from a resident table though and it seems not working . Can i run this rotate(right) command with a load from a resident table ? 

Thanks in advance

Vladimir

Taoufiq_Zarra

OK

attahced, a  new way :

Data:

LOAD * INLINE [
Months, Sales, Profit
Jan, 1M , 100K
Feb ,2M , 200K
March , 3M     , 300K
];


let NumRows=NoOfRows('Data');
Let vcount =NoOfFields('Data');
FOR i=0 to $(NumRows)-1
	For j=2 to $(vcount)

 		 LET Value=Peek(FieldName($(j),'Data'),$(i),'Data');
 		 let title=Peek(FieldName(1,'Data'),$(i),'Data');
 		  let title2=FieldName($(j),'Data');

 load 
'$(title2)' AS Title,
 '$(Value)' as '$(title)'
 autogenerate(1);

NEXT;
NEXT;

drop table Data;

 

 

Capture.PNG

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
vladimirkup
Contributor III
Contributor III
Author

Hi,

That seems almost there. Can you just show how to put the results in one new table instead of having it in Autogenerate(1), Autogenerate(1) - 1, Autogenerate(1) - 2

 

Thanks

Aspiring_Developer
Specialist
Specialist

Hi @Taoufiq_Zarra 

I have a similar set of query , could you please help me with the below scenario :-

UserID UserNumber Feedback YN Question
29 11111111 YES Q1) Did you completed the day one activities ?
30 11111111 YES Q2)Did you share the infomration with customer ?
31 11111111 N/A Q3) Did you escalate if required ?
32 11111111 YES Q4Did you follow the closure process ?

 

And I wish to achieve the below output :-

UserID User Number Q1) Did you completed the day one activities ? Q2)Did you share the information with customer ? Q3) Did you escalate if required ? Q4) Did you follow the closure process ?
29 11111111 YES      
30 11111111   YES    
31       N/A  
32         Yes

 

I tried your solution but I could not able to do it correctly with my data as I need the other fields as well. Could you please help me with this ?

I cannot use the generic load solution here as it results in creation of multiple tables and synthetic keys .

Thanks