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: 
wossenhh
Creator
Creator

How to trimming text out of numbers?

Hi,

I have a combination of text and numbers and would like to trim as follows:

Name                                                       What should be the result

CRIcecream_W1_160x600_Static          CR Ice cream

BeefSausage_W3_300x250                    Beef Sausage

Is there any way of doing that? Basically to trim anything after _w* and then to make a space like (CR Ice Cream, Beef Sausage)

Thanks,

Wossen

1 Solution

Accepted Solutions
Not applicable

You do not need to use trim. Just:

subfield([Creative Messsage],'_',1) as Creative1

View solution in original post

12 Replies
Not applicable

subfield(Name,'_',1) should do the trick. This however won't add spaces.

swuehl
MVP
MVP

The first issue could maybe achieved with

subfield( Name, '_',1) as NewName

But how to add the spaces as spearators? I have no clue, if your Names are not known. If you know possible values, you can try a mapping approach.

Not applicable

I am not sure that there is an easy way to add in spaces in this case.

wossenhh
Creator
Creator
Author

Thanks all, I tried  your suggestion subfield(Name,'_',1) as NewName, however it didn't work.

Not applicable

Are you using the subfield function in your load script or in the app itself?

wossenhh
Creator
Creator
Author

Hi Jacob,

I did in load script and also tried in Edit expression in the listbox.

Not applicable

Can you post your qvw?

wossenhh
Creator
Creator
Author

Here is what shows in load script:

Load

      [Creative Message],

      text ([Creative Message]) as Creative,

      Trim(subfield([Creative Message], '_',1)) as Creative1

Do you see anything wrong with the above script Jacob?

Not applicable

You do not need to use trim. Just:

subfield([Creative Messsage],'_',1) as Creative1