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: 
hopkinsc
Partner - Specialist III
Partner - Specialist III

get first 3 characters of field

Hi all,

i have a field that i am currently stripping all numbers from.

PurgeChar([Cell Name],'0123456789') as [BaseStation Name],

but i have found that for some particular values of this field i need to keep the first number.

here is an example of the values..

[Cell Name]

ADDAX1

ADDAX2

ADDAX3

PLU1

PLU2

PLU3

BO31

BO32

BO33

BO41

BO42

BO43

BO51

BO52

what i want is an if statement before my Purgechar statement to say that if the Cell name =BO* then take the first 3 characters (i.e. BO3, BO4 etc) otherwise do my purgechar statement.

I cant seem to get it to work, can anyone help?

1 Solution

Accepted Solutions
stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

You will need this:

if(left([Cell Name], 2) = 'BO', left([Cell Name], 3), purgechar([Cell Name], '0123456789')) as [BaseStation Name],

Hope that helps,

Steve

View solution in original post

5 Replies
Not applicable

hi

left([Cell Name],3)

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

You will need this:

if(left([Cell Name], 2) = 'BO', left([Cell Name], 3), purgechar([Cell Name], '0123456789')) as [BaseStation Name],

Hope that helps,

Steve

Not applicable

hi

if(wildmatch([Cell Name],'BO*'),left([Cell Name],3),[Cell Name]) as new_[Cell Name]

MK_QSL
MVP
MVP

IF(LEN(PurgeChar([Cell Name],'0123456789'))>3, 

     PurgeChar([Cell Name],'0123456789'),

     Left([Cell Name],3)) as [BaseStation Name],

Colin-Albert
Partner - Champion
Partner - Champion

if(left(YourField,2) = 'BO', left(YourField,3), YourPurgeCharExpression) as NewField