Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
sudeepkm
Specialist III
Specialist III

Generating blank spaces based on field value length

Hi,

I've a table like below

sample:

load * Inline [

id,name

1,abc

2,abcd

3,abcde

4,abcdef

];

I'm looking for a solution using which I would be able to create another field which will have spaces[' '] based on the length of the field 'name'. for example the table with the new field (fieldlen) should look like below

id,name,fieldlen

1, abc, '   '

2, abcd, '    '

3, abcde, '     '

4, abcdef, '      '

for id = 1 the fieldlen value should be 3 spaces and for id=2 the fieldlen value should be 4 spaces and so on.

Thanks in advance.

Thanks and Regards,

Sudeep

1 Solution

Accepted Solutions
juleshartley
Specialist
Specialist

Try

repeat(' ',len([name]))

View solution in original post

6 Replies
juleshartley
Specialist
Specialist

Try

repeat(' ',len([name]))

Not applicable

Attached with answer. Its a little tedious, but once set up it will be good.

Thanks

kushalthakral
Creator III
Creator III

Hi Ajay

your solution is good but what if we have 100 of records and having different combinations..

Regards

Kushal T

Not applicable

It will still work. You just need to first set up for the 26 alphabets once. Once thats done, then the code is the same irrespective of the # of records.

kushalthakral
Creator III
Creator III

Okk, we can simply write repeat with length statement in script so no need to create inline table

Regards

Kushal T

Not applicable

Yeah. That seems like a simpler option. Mine is just another way of approaching the same issue.

Repeat() is definitely an ideal solution.