Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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...
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
];
I'm sorry but I did not understand you. Can you give an example on what you want to achieve?
Will you provide an example of the data and the expected outcome?
I want to turn this:
ID | Field |
1 | Field to be split. |
into this:
ID | New_Field |
1 | F |
1 | i |
1 | e |
1 | l |
1 | d |
1 | |
1 | t |
1 | o |
1 | |
1 | b |
1 | e |
1 | |
1 | s |
1 | p |
1 | l |
1 | i |
1 | t |
1 | . |
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
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
];
Perfect. Thank you.