Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
nachiket_shinde
Contributor III
Contributor III

Reverse order in QVD

Hello Friends,

I have  QVDs for each day which has following data(userdata_20170314 to userdata_20190314.qvd)

IDuser1user2user3user4user5
1ABCDE
2ABC  
3AB   
4ABCD 
5A    

I am not sure for which ID how many users may have value.

For QVDSfrom 'userdata_20170314' to 'userdata_20180314' , i want to change data as per below

IDuser1user2user3user4user5
1EDCBA
2CBA  
3BA   
4DCBA 
5A    

 

In short we are reversing all values.

Please suggest.

 

 

Thanks in advance

1 Solution

Accepted Solutions
Vegar
MVP
MVP

It is a bit tricky, but this script will do the trick for rading your special period files.

OUTPUT:
LOAD
  ID,
  SubField(Users, '|', -1) as user1,
  SubField(Users, '|', -2) as user2,
  SubField(Users, '|', -3) as user3,
  SubField(Users, '|', -4) as user4,
  SubField(Users, '|', -5) as user5
  ;
LOAD 
 ID, 
  user1 &if(len(user2)>0,'|'&user2)&if(len(user3)>0,'|'&user3)&if(len(user4)>0,'|'&user4)&if(len(user5)>0,'|'&user5) as Users
FROM
SOURCEDATA;

image.png

View solution in original post

3 Replies
Vegar
MVP
MVP

It is a bit tricky, but this script will do the trick for rading your special period files.

OUTPUT:
LOAD
  ID,
  SubField(Users, '|', -1) as user1,
  SubField(Users, '|', -2) as user2,
  SubField(Users, '|', -3) as user3,
  SubField(Users, '|', -4) as user4,
  SubField(Users, '|', -5) as user5
  ;
LOAD 
 ID, 
  user1 &if(len(user2)>0,'|'&user2)&if(len(user3)>0,'|'&user3)&if(len(user4)>0,'|'&user4)&if(len(user5)>0,'|'&user5) as Users
FROM
SOURCEDATA;

image.png

nachiket_shinde
Contributor III
Contributor III
Author

This is working as expected.

Thanks a lot for your help.

nachiket_shinde
Contributor III
Contributor III
Author

Hello Vegar,

 

I have another situation here.

What if my data is as below

IDuser1user2user3user4user5
1A-BCD
2CD-QP
3ABC  
4S-C-B

 

And expected is

IDuser1user2user3user4user5
1DCB-A
2PQ-DC
3CBA  
4B-C-S

 

Thanks in advance.