Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

gsrchowdary
New Contributor

Splitting string into coloumns

Hi Friends,

I have a string like b-bghy-gnhytr-df-fgt.Need to split into 5 coloumns.

As well its size is not fixed..

Can any one help on this..

9 Replies
consenit
Contributor II

Re: Splitting string into coloumns

Hi there.

Look up the SubField() string function.

Kind regards,

Ernesto.

saurabh5
Contributor II

Re: Splitting string into coloumns

hi shiva,

As Ernesto mentioned use subfield function, below is script which will help you split into 5 columns

trigger:

load * inline [
word, number
b-bghy-gnhytr-df-fgt, 1

]
;

trigger2:
load number,
SubField(word,'-',1) as one,
SubField(word,'-',2) as two,
SubField(word,'-',3) as three,
SubField(word,'-',4) as four,
SubField(word,'-',-1) as five
resident trigger;


MVP
MVP

Re: Splitting string into coloumns

RESULT

1.png

SCRIPT

a:

load * inline [

word, number

b-bghy-gnhytr-df-fgt, 1

];

b:

load number,

SubField(word,'-') as newfield

resident a

;

Re: Splitting string into coloumns

Hi,

one solution could be:

QlikCommunity_Thread_146373_Pic1.JPG

tabStrings:

Generic

LOAD RecNo() as %ID,

    'Sub'&Autonumber(RowNo(),RecNo()) as ColNo,

    SubField(string,'-') as substring

Inline [

string

b-bghy-gnhytr-df-fgt

sdf-sfdsfd-sdf-sdf-sf

sdfs-sfd-sdf-sf

egr-rht-tzj

tjt-iuk

wre

wrer-retz-zu-wre-tzo

zuk-rt-we-jhk-fh-etr

];

hope this helps

regards

Marco

rustyfishbones
Honored Contributor II

Re: Splitting string into coloumns

Use SUBFIELD Function like below image

2014-12-20_1147.png

alkesh_sharma
Contributor III

Re: Splitting string into coloumns

Use SubFiled() Function

Re: Splitting string into coloumns

Any luck testing the proposed solutions so far?

gsrchowdary
New Contributor

Re: Splitting string into coloumns

Hi yes i tried and its working

Re: Splitting string into coloumns

Hi,

good to hear.

Please close this thread.

thanks

regards

Marco