Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Leverage your QlikView investment to modernize BI – see how! Join Group
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Creator
Creator

Remove characters at start of string

Hi all,

I know this is a popular one, and I've read many threads about string functions but I can't seem to put one together to fit this particular need.

I wish to remove any character before a name. This name is preceded by numbers and spaces and a hyphen, and sometimes another separator (usually a dot). Examples are:

1 - Name

12 - Name

23 -  Name

3.1 - Name

2- Name

2-Name

Name

2.5 - Name - SecondPartofName

I've tried various combinations of Trim(), Mid(), Left(), PurgeChar() but don't seem to be able to just keep the name.

I've considered using if()'s but I'm trying to keep the script fast as I'll be using this on lots of imported fields.

Any ideas?

Many thanks.

1 Solution

Accepted Solutions
Highlighted

Re: Remove characters at start of string

Sample script

Table:

LOAD *,

Trim(Mid(FieldName, Index(FieldName, '-') + 1)) as Name;

LOAD * INLINE [

    FieldName

    1 - Name

    12 - Name

    23 -  Name

    3.1 - Name

    2- Name

    2-Name

    Name

    2.5 - Name - SecondPartofName

];

Which give me this

Capture.PNG

View solution in original post

6 Replies
Highlighted

Re: Remove characters at start of string

use trim(subfield(fieldName,'-',2))

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Highlighted
Partner
Partner

Re: Remove characters at start of string

Try with

Trim(SubField(YourField,'-',2)) as Name

Highlighted
Creator
Creator

Re: Remove characters at start of string

Thanks for the suggestion,

Unfortunately the Name sometimes also has a hyphen within the name. This gets rid of everything after the second hyphen too.

Highlighted

Re: Remove characters at start of string

May be this

Trim(Mid(FieldName, Index(FieldName, '-') + 1)) as Name

Highlighted

Re: Remove characters at start of string

Sample script

Table:

LOAD *,

Trim(Mid(FieldName, Index(FieldName, '-') + 1)) as Name;

LOAD * INLINE [

    FieldName

    1 - Name

    12 - Name

    23 -  Name

    3.1 - Name

    2- Name

    2-Name

    Name

    2.5 - Name - SecondPartofName

];

Which give me this

Capture.PNG

View solution in original post

Highlighted
Creator
Creator

Re: Remove characters at start of string

Sunny!

I wondered how long it would take you

Thank you very much again that worked perfectly.