Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
tr99
Contributor
Contributor

Subfield() all characters of string

Is it possible to split each element  of a field? It seems like subfield([FIELD],'') would work but it doesn't. 

I would rather not get into tedious loops for such a simple task...

1 Solution

Accepted Solutions
fosuzuki
Partner - Specialist III
Partner - Specialist III

Then you can't use subfield(), because it requires a delimiter.

But this will work:

load ID,
mid(Field, iterno(), 1) as New,
iterno() as Order
while IterNo() < len(Field);
load * inline [
ID,Field
1,Field to be split
2,Another field
];

View solution in original post

6 Replies
fosuzuki
Partner - Specialist III
Partner - Specialist III

I'm sorry but I did not understand you. Can you give an example on what you want to achieve?

Tanalex
Creator II
Creator II

Will you provide an example of the data and the expected outcome?

tr99
Contributor
Contributor
Author

I want to turn this:

IDField
1Field to be split.

 

into this:

IDNew_Field
1F
1i
1e
1l
1d
1 
1t
1o
1 
1b
1e
1 
1s
1p
1l
1i
1t
1.
jpenuliar
Partner - Specialist III
Partner - Specialist III

You can do a nested For loop to achieve your result.

see below:

Test:
Load * Inline [
ID,Field
1,'Field to be split.'
2,'Another Field to be split.'
];

 

FOR Each a in FieldValueList('Field')

LET vlen = Len(a);
Trace $(vlen);

for b=1 to $(vlen)

Temp:
Load
'$(a)' as 'NewField',
'$(b)' as 'integer',
Mid('$(a)',$(b),1) as 'value'
AutoGenerate 1;

next

NEXT a

fosuzuki
Partner - Specialist III
Partner - Specialist III

Then you can't use subfield(), because it requires a delimiter.

But this will work:

load ID,
mid(Field, iterno(), 1) as New,
iterno() as Order
while IterNo() < len(Field);
load * inline [
ID,Field
1,Field to be split
2,Another field
];

tr99
Contributor
Contributor
Author

Perfect. Thank you.