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: 
didierodayo
Partner - Creator III
Partner - Creator III

Dynamic field renaming

Hello,

I need some help with this scenario.

I have let say 3 QVDs .

qvdtable1

TYPE DATE  qvdtable1_ID

qvdtable2

TYPE DATE  qvdtable2_ID

qvdtable3

TYPE DATE  qvdtable3_ID

I am trying to load all the QVDs  in one script but dynamically rename the qvdtable*_ID To ID.


How could this be achieved?


Thanks

1 Solution

Accepted Solutions
sam_grounds
Contributor III
Contributor III

Sounds like you want the FileName() function... This will return the full name of the file including .qvd extension. If the only number in the name is what you want to keep, simply use KeepChar() to purge everything but numbers from the name. Example below.

Load

     qvdtable$(KeepChar(FileName(),'0123456789')).ID as ID,

     Type,

     Date

From qvdtable*.qvd (qvd);

Alternatively you could loop through the tables.

For Each vIteration In FileList('FileLocation\qvdtable*.qvd')

Load

     qvdtable$(vIteration).ID as ID,

     Type,

     Date

next vIteration;

However you might have some issues if you don't have a sequential list of numbers.

Thanks,

Sam

View solution in original post

3 Replies
arvind_patil
Partner - Specialist III
Partner - Specialist III

Hi Didier,

Use Qualify for dynamic renaming your fileds just Give tablename like Qvd1

Then Field name will display like Qvd1.ID

Thanks,

Arvind Patil

sam_grounds
Contributor III
Contributor III

Sounds like you want the FileName() function... This will return the full name of the file including .qvd extension. If the only number in the name is what you want to keep, simply use KeepChar() to purge everything but numbers from the name. Example below.

Load

     qvdtable$(KeepChar(FileName(),'0123456789')).ID as ID,

     Type,

     Date

From qvdtable*.qvd (qvd);

Alternatively you could loop through the tables.

For Each vIteration In FileList('FileLocation\qvdtable*.qvd')

Load

     qvdtable$(vIteration).ID as ID,

     Type,

     Date

next vIteration;

However you might have some issues if you don't have a sequential list of numbers.

Thanks,

Sam

effinty2112
Master
Master

Hi Didier,

I think Sam has given you excellent advice that looks like the correct answer to me. I just want to say that if you try another method like renaming after loading the tables you will have problems because QV won't allow you to change a field name to one that already exists in a resident table. If you know that already then apologies, I only mention it because I remember when I had an issue with that until I realised I was trying to do something QV wouldn't allow.

Cheers

Andrew