Discussion Board for collaboration on QlikView Scripting.
I have a table like this :
And I want to split the secondary field in parts of 7 chars.
I thought to use "subfield", but I need a char to reference the split, and I don't know how to insert a "diferential" chart every seven chars.
My result would be :
How could I do this?
Many thanks in advance.
Go to Solution.
Try like this also,
Load * Inline
Let vLen =0;
For j= 0 to NoOfRows('Table1')-1
vLen = 0;
Let vField1= Peek('SF',$(j),'Table1');
Let vField2 = Peek('MF',$(j),'Table1');
For i=0 to len(vField1)
if mod($(i),7) = 0 then
Load Mid('$(vField1)', $(vLen)*7+1, 7) as SF1, $(vField2 ) as MF AutoGenerate 1;
vLen = $(vLen)+1;
But cleveranjos is an optimized way. This is also one way
This code below does what you want
LOAD * INLINE [
F1 as [Main Field],
F2 as [Secondary Field],
IterNo() as i,
Mid(F2,(IterNo()-1) * 7+1, 7) as [Third Field]
While IterNo() <= div(len(F2),7)+1;
Clever Anjos , Mayil Vahanan Ramasamy,
Your both solutions are fine. I'm just adding one more
Source:LOAD * INLINE [ Main, Second 1, qwertyuiopasdfghjklñzxcvbnm 2, mnbvcxzñlkjhgfdsapoiuytrewqopsasasasa ];
FOR n=0 TO 100 // the "limit" is hardcoded here, but can be pre-calculated in a variable Result: LOAD Main, mid(Second, $(n)*7+1, 7) as Third RESIDENT Source WHERE len(mid(Second, $(n)*7+1, 7))>0;NEXT
Thanks Guys! It works like a charm! The 3 solutions did what I need.