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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
beneldridge
Partner - Contributor
Partner - Contributor

Changing text via the script

Hi,

Can someone tell me how to change the text of something in the script?

I am wanting to make several slight changes to a column for example I would like to make such changes like "Assets London" to "Ass London" and "Assets Manchester" to "Ass Manchester" without having to create another column?

Thanks,

Ben

7 Replies
rubenmarin

Hi Ben, you can use a mapping table, this is a table with 2 columns: one iis the value to search and the 2nd the value returned.

mapText:

LOAD * inline [

TextFrom, TextTo

Assets London, Ass London

Assets Manchester, Ass Manchester

];


And use applymap when loading the text field:

LOAD 

  Applymap('mapText', TextField) as TextField

...

If some value is not found in the mapText table the default value is kept.

https://help.qlik.com/en-US/qlikview/November2017/Subsystems/Client/Content/Scripting/MappingFunctio...

sunny_talwar

May be use a Mapping load to get this resolved

LivingQlik Roots: The Complete Guide to QlikView Mapping Load

beneldridge
Partner - Contributor
Partner - Contributor
Author

Hi Ruben,

Thanks for getting back to me, I tried adding the below to my coding but it did not like it. I am pretty much new to Qlikview so it is pretty alien to me, but enjoying the challenge. Are you able to help me some more?

Thanks,

Ben

LOAD * inline [

TextFrom, TextTo

Assets London, Ass London

Assets Manchester, Ass Manchester

];

sunny_talwar

I think you missed the Mapping keyword

MappingTable:

Mapping

LOAD * inline [

TextFrom, TextTo

Assets London, Ass London

Assets Manchester, Ass Manchester

];

awhitfield
Partner - Champion
Partner - Champion

Ha ha, that's a really bad abbrv. for Assets!

Andy

beneldridge
Partner - Contributor
Partner - Contributor
Author

Thanks Sunny,

I am still getting a script error saying: Field Not Found - <Business Unit> followed by the script I tried to add?

Thanks,

Ben

Colin-Albert
Partner - Champion
Partner - Champion

Another option would be to use replace() to change 'Assets' to 'Ass'

Something along the lines of

Load

     replace(your_field_name, 'Assets', 'Ass') as your_field_name,

     ....

     from .... ;

You can also nest multiple replace statements together

     replace(replace(your_field_name, 'Assets', 'Ass'), 'AAA', XXX') as your_field_name,

If there are lots of changes, then the mapping table method is easier to maintain.