Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
shekhar_analyti
Specialist
Specialist

How to split a single string into individual letters ? Is there any function ?

Hi All ,

How to split a single string into individual letters ?

Example : A field called PASSWORD has values

PASSWORD

@aklipo

3!5576

i want to split them like

@                                                     and                      @     k    l   i    p   o

a

k

l

i

p

o

and store in table , so that table is read by reading software .

Thanks & Regards

Shekar

18 Replies
shekhar_analyti
Specialist
Specialist
Author

I want each letters in separate columns with column name as Letter1 , Letter2 , Letter3 .... and so on

Example

PASSWORD   Letter1   Letter2 Letter3  ............... Letter(i)

CAR                  C           A            R

t_chetirbok
Creator III
Creator III

for columns

PASS:

load * Inline

[

PASSWORD

@aklipo

3!5576

yhF&kd#1

]

;

max:

load max(len(PASSWORD)) as Max_Size Resident PASS;

let Num =  peek('Max_Size') ;

drop Table max;

sub filling(Number)

left join(PASS)

load PASSWORD , if(len(PASSWORD)>=$(Number),mid(PASSWORD,$(Number),1),null()) as Letter$(Number) Resident PASS;

ENDSUB

for i=1 to $(Num)

call filling($(i));

next

shekhar_analyti
Specialist
Specialist
Author

Take a bow

shekhar_analyti
Specialist
Specialist
Author

Please help me understanding $(Number)


if(len(PASSWORD)>=$(Number)

t_chetirbok
Creator III
Creator III

$(Number) is a variable for creating and filling new fields

the procedure is called in a loop

call filling(1) - will create one new field Letter1

the condition if(len(PASSWORD)>=$(Number) is used for checking if the letter that we want to create is still in the password or we separated all letters.

for example call filling(8): in @aklipo 7 letters, that means we should put "letter8" column null value

I hope my explanation was clear)

MarcoWedel

Hi,

another solution might be:

QlikCommunity_Thread_285778_Pic1.JPG

table1:

Generic

LOAD *,

    'Char'&IterNo(),

    Mid(PASSWORD,IterNo(),1)

INLINE [

    PASSWORD

    @aklipo

    3!5576

] While IterNo()<=Len(PASSWORD);

hope this helps

regards

Marco

tresesco
MVP
MVP

Hi Marco,

I was trying to achieve the similar - separated characters in listbox looping through the value characters purely in the UI. I was trying with valueloop(). But could not manage to do it.  I have seen some tricky and nice solutions from you. Could you please give this a try too?

shekhar_analyti
Specialist
Specialist
Author

Thank you all for the solution ...

MarcoWedel

Hi,

maybe these examples might be helpful?

QlikCommunity_Thread_285778_Pic12.JPG

QlikCommunity_Thread_285778_Pic3.JPG

QlikCommunity_Thread_285778_Pic9.JPG

QlikCommunity_Thread_285778_Pic4.JPG

QlikCommunity_Thread_285778_Pic10.JPG

QlikCommunity_Thread_285778_Pic5.JPG

QlikCommunity_Thread_285778_Pic11.JPG

QlikCommunity_Thread_285778_Pic6.JPG

QlikCommunity_Thread_285778_Pic7.JPG

QlikCommunity_Thread_285778_Pic8.JPG

table1:

LOAD Text(PASSWORD) as PASSWORD

Inline [

    PASSWORD

    @aklipo

    3!5576

    Password

    P@$$w0rd

    MySecret

    Test

    1234

    12345

    qwerty

    1q2w3e   

];

Marco