Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Only at Qlik Connect! Guest keynote Jesse Cole shares his secrets for daring to be different. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
micheledenardi
Specialist II
Specialist II

split string value

i have some strings like:

'this is the first string  5862'

'this is the second string 0'

'this is the third string 23'

and i want to separate every string in two parts, one for the text of the string and one for the numeric part to obtain:

'this is the first string'  '5862'

'this is the second string' '0'

'this is the third string' '23'

can someone help me ?

thank's

Michele De Nardi
If a post helps to resolve your issue, please accept it as a Solution.
1 Solution

Accepted Solutions
maxgro
MVP
MVP

this is the result (text and numberfields) using my previous answer

1.jpg

View solution in original post

6 Replies
maxgro
MVP
MVP

hope to understand

number is always the last word

blank between words

RESULT:

1.jpg


SCRIPT:

t:

load string, left(string, index(string,number)-1) as text, number;

load *, subfield(string, ' ', -1) as number inline [

string

'this is the first string  5862'

'this is the second string 0'

'this is the third string 23'

];

rubenmarin

Hi Michele, It's always text + blank_space + number? In this case you can use:

First part: Left(StringField, Index(StringField, ' ', -1))

Second part: Mid(StringField, Index(StringField, ' ', -1)+1)

          or:      Subfield(StringField, ' ', -1)

Not applicable

Hi Michele,

if there isn't always a set format in the values, extra spaces etc etc

then you could use purse and keep char functions

KeepChar([myField],'0123456789') AS number

PurgeChar([myField],'0123456789') AS text

hope that helps

Joe

micheledenardi
Specialist II
Specialist II
Author

hi ruben, no, the string can be composed by text+blank space+number +text + number and i want to separate the final number from the rest of the string

Michele De Nardi
If a post helps to resolve your issue, please accept it as a Solution.
micheledenardi
Specialist II
Specialist II
Author

hi joe,

i can't use keep and purse funcion because my string are composed like

'this is string1  0'

'this is string 2  58'

this is string 3 5869'

and i want to retrive

'this is string1'  '0'

'this is string 2'  '58'

this is string 3' '5869'

Michele De Nardi
If a post helps to resolve your issue, please accept it as a Solution.
maxgro
MVP
MVP

this is the result (text and numberfields) using my previous answer

1.jpg