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: 
leo88
Contributor
Contributor

Replacing field or table content

Hey guys,
I would like you to help me with a script. I need to create a column by replacing the textual content from another existing column, for example:

Coke 2L ---> 2L
Sugar 1KG ---> 1KG
Flour 5KG ---> 5KG
.... 
Can you guide me how to implement this? I believe I have to replace the letters until I get the goal, but I don't know how to start. Thanks.

Labels (1)
4 Replies
Vegar
MVP
MVP

You could try to use subfield() for this.

Subfield ([YourStringField], ' ', -1)  

 

leo88
Contributor
Contributor
Author

ok, but sometimes the field content can be complex or open, and I still want to extract the unit correctly.
 
I think of creating a routine that can read a part of the content and transform it into what I want, for example:
Coke (2 L) or Coke (2 L)iters ---> 2L Sugar (5 KG) or Sugar (5 K)ilos ---> 5KG thanks
leo88
Contributor
Contributor
Author

Hello Guys, 

I am trying to use the replace function, but I realized that Qlikview can implement it just 100 times (ie. Replace(Replace( text, 'A', 'a'), 'B', 'b')....., 'ZZZ', 'zzz'). I need to use more than 200 replaces, can somebody tell me a way to do it?Thanks

Vegar
MVP
MVP

Take a look at the MapSubstring() function. It might be a good fit for your scenario.