Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
felcar2013
Partner - Creator III
Partner - Creator III

Replacing script field names using mapping table

HI

i have a big script and unfortunately we changed field names in the data base which affects my qvds and other parts of the script

I wanted to know, if it is possible to replace the Fieldname_1 with the fieldname_2 at once in all the script tabs with a do-while-loop statement. I was using the Find / Replace, but it is too manual and it is getting caothic. Besides, you see that i need not only to replace the first word "contact" with "member" but also, in some cases, the second part of the string, like in the

"contact_DummyCustomer" with "member_NonMember". Is there a "replace" function in the script that evaluates the current field, compare it and then based on the condition "replaces" it accordingly?

mapping table:

TABLE.png

13 Replies
jeffmartins
Partner - Creator II
Partner - Creator II

Hi felcar2013,

You need to put the code "Rename fields using FieldMap" at the end of the script.

The fields are only renamed after the code "Rename fields using FieldMap".

Regards

felcar2013
Partner - Creator III
Partner - Creator III
Author

thanks

but it did not work. I need to a kind of "find/replace" function that goes through all tables and fieldnames in the script and replace the old fields with the new fields. This shall happen for 200 different field names.

I can just not execute the script without getting a lot of field name erros, since it loads from qvd files, which already have the new names, that were changed in the data source (sql database).

thanks anyway

devans_1
Creator
Creator

Can you set a variable using SET and use this variable ? That way you only need to change the field once at the top of the script ?

SET field1 = "contact_periodID";

LOAD $(field1)

etc.

felcar2013
Partner - Creator III
Partner - Creator III
Author

the mapping solution with rename fields works when i load inline, not when i need to load from external data sources. Besides, it seems that the fields are changed in-memory, not in the script, what is what i need.

David, i will see your option, even though i already changed everything manually 🙂 took some time, but i wanted to automate it and need to continue trying, since this will happen again,

best

felipe