Discussion Board for collaboration on QlikView Scripting.
I have a table which needs to transform.
My table A looks like this:
From this base, I need I table like this:
Have someone a solution for this problem?
I have an idea, but I don't know how to implement.
I sort my table. First the quantity.
In the second the Key
Now I need a new colum.
key(from row) = key(from row -1),
numberOfKey(from row-1) + 1,
If I get a table like this I can transform these.
where numberOfKey = 1;
outer join (newA)
where numberOfKey = 2;
I hope somebody can help me.
Go to Solution.
You Almost got the solution. Just i created script based on your steps..
T1: LOAD * INLINE [ Key, quantity, Price 1, 1, 1.5 1, 5, 3.7 1, 10, 4.8 2, 1, 2.45 2, 5, 8.45 3, 4, 5.45 3, 1, 6.45 3, 6, 8.45 6, 8, 6.21 6, 1, 8.45 7, 10, 1.28 ]; NoConcatenate T2: LOAD *,if(Key=Previous(Key) and RowNo()<>1,Peek('Key1')+1,1) as Key1 Resident T1 Order by Key,quantity asc; DROP Table T1; NoConcatenate newA: LOAD Key,quantity as quantity1,Price as Price1 Resident T2 Where Key1=1; Outer Join(newA) LOAD Key,quantity as quantity2,Price as Price2 Resident T2 Where Key1=2; Outer Join(newA) LOAD Key,quantity as quantity3,Price as Price3 Resident T2 Where Key1=3; DROP Table T2;
Note: Even we can simplify this using for loop (as i know)
a solution without hard coded field names could use a generic load:
The Generic Load
hope this helps
The Generic Load script would be pretty simple in this case:
'Quantity' & AutoNumber(RecNo(), Key),
(html, codepage is 1252, embedded labels, table is @1);
'Price' & AutoNumber(RecNo(), Key),
Thanks for the solution! It works well!