Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
MuraliPrasath
Creator III
Creator III

Trim Function Question.

Hi,

I want show only the first two letters in my field. how to achieve this?

Ex:

Field:

ABAS

SDFW

1244S

SDFG

SD646

545SD

SDE12

124563

12448L

SDFGL

145877

I need only the first two letter's not numbers.

Expecting Result:

Field:

AB

SD

SD

SD

SD

SD

Need help!

1 Solution

Accepted Solutions
jayanttibhe
Creator III
Creator III

Use following :

PurgeChar(Left([Field:],2), '1234567890')

View solution in original post

12 Replies
Peter_Cammaert
Partner - Champion III
Partner - Champion III

left(FieldName, 2)

Is this to be shown in a listbox? I guess not. Where do you want this to happen?

jayanttibhe
Creator III
Creator III

Use following :

PurgeChar(Left([Field:],2), '1234567890')

sunny_talwar

May be this:

LOAD Field,

           If(IsText(Left(Field, 2)), Left(Field, 2)) as NewField

FROM ....

New field will only have two letters where they are text and not number. But it will include a value like 1A or B3

Anil_Babu_Samineni

Sunny, How about if values are like below

Field:

ABAS

SDFW

1244S

SDFG

SD646

545SD

SDE12

124563

12448L

SDFGL

145877

A123

May be this?

If(Index(Field,'AB'),'AB', If(Index(Field,'SD'),'SD')) as NewField

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
sunny_talwar

Like I said, my way would include A1.... but the issue with your code is that it won't include CD7264 for example

jayanttibhe
Creator III
Creator III

Well he wanted first 2 letters and not numbers: The first 2 letters may be anything . AB OR SD are just examples I think.  His requirement is bit unclear - I guess he dont want anything if there is any numeric value .

I have taken care of it in my expression.

MuraliPrasath
Creator III
Creator III
Author

Thank you 🙂  It Worked.

Peter_Cammaert
Partner - Champion III
Partner - Champion III

But your solution isn't correct either. You would end up with 6 times an SD value, while Murali only lists 5 of them.

I think the expression will be a bit more complex. Something along the lines of

IF (Len(Left(PurgeChar(Field, '1234567890'), 2) = 2,

        Left(PurgeChar(Field, '1234567890'), 2))

And then we all hope for a QlikView expression optimiser, don't we?

Peter_Cammaert
Partner - Champion III
Partner - Champion III

OK.

Please post correct requirements next time.