Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join us at the Cloud Data and Analytics Tour! REGISTER TODAY
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

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

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'

maxgro
MVP
MVP

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

1.jpg

View solution in original post