Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
Try
repeat(' ',len([name]))
Attached with answer. Its a little tedious, but once set up it will be good.
Thanks
Hi Ajay
your solution is good but what if we have 100 of records and having different combinations..
Regards
Kushal T
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.
Okk, we can simply write repeat with length statement in script so no need to create inline table
Regards
Kushal T
Yeah. That seems like a simpler option. Mine is just another way of approaching the same issue.
Repeat() is definitely an ideal solution.