Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
louwriet
Creator
Creator

Test if a string contain any numbers in load script

Hi,

I need to test if a string in a field contain any numbers , if yes then group it in 'OTHER' else if the string in field contain no numbers then the field value stay the same.

But there are no fix order for the number to appear in the string - so i cannot test spesific positions. String can look like 'HARBOUR'  then it will remain 'HARBOUR' and in the case of 'HARBOUR77' it must change to 'OTHER'

At the end my field in the records will look like this

GroupName

=========

HARBOUR

PORT

OTHER

LOADDECK

OTHER

ect.....

it would be something like     if(field1 = num(whatever) , 'OTHER', field1)  as Groupname

Help would be appreciated

Regards

Louw

1 Solution

Accepted Solutions
sunny_talwar

May be this:

If(Len(Trim(KeepChar(Field1, '0123456789'))) > 0, 'OTHER', Field1) as GroupName

View solution in original post

4 Replies
sunny_talwar

May be this:

If(Len(Trim(KeepChar(Field1, '0123456789'))) > 0, 'OTHER', Field1) as GroupName

m_woolf
Master II
Master II

If(YourField = purgechar(YourField,'0123456789'),'There are no numbers','There is at least one number')

louwriet
Creator
Creator
Author

Thank you for both of you, Sunny T and M Woolf, both of the solutions you gave me worked.

regards

Louw

Daniel-PNW
Contributor III
Contributor III

Totally help me weed out my list of results!!! Thanks so much.