Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Good morning How can I get this result from the qlikview script?
Source Table
Pos CTASTART CTAEND Status
52 5720000 5720000 X
55 4000000 4000999 S // Example, records to create from 4000000 to 4000999
76 4300001 4300002 U
Qvd destination
Pos CTA Status
52 5720000 X
55 4000000 S
55 4000001 S
55 4000002 S
55 ... S
55 4000999 S
76 4300001 U
79 4300002 U
Thanks for your help
maye be
Script :
Data:
load num(CTAEND-CTASTART) as NB,* inline [
Pos,CTASTART,CTAEND,Status
52,5720000,5720000,X
55,4000000,4000999,S
76,4300001,4300002,U
];
output:
LET NumRows=NoOfRows('Data');
FOR i=0 to $(NumRows)-1
LET vPos=Peek('Pos','$(i)','Data');
LET vCTASTART=Peek('CTASTART','$(i)','Data');
LET vCTAEND=Peek('CTAEND','$(i)','Data');
LET vStatus=Peek('Status','$(i)','Data');
let Numsubrow=Peek('NB','$(i)','Data');
for ii=0 to '$(Numsubrow)'
load '$(vPos)' as New_Pos,'$(vCTASTART)'+'$(ii)' as CTA, '$(vStatus)' as New_Status,'$(i)' as i,'$(ii)' as ii
autogenerate 1;
Next
Next
drop table Data;
drop field i,ii;
output:
maye be
Script :
Data:
load num(CTAEND-CTASTART) as NB,* inline [
Pos,CTASTART,CTAEND,Status
52,5720000,5720000,X
55,4000000,4000999,S
76,4300001,4300002,U
];
output:
LET NumRows=NoOfRows('Data');
FOR i=0 to $(NumRows)-1
LET vPos=Peek('Pos','$(i)','Data');
LET vCTASTART=Peek('CTASTART','$(i)','Data');
LET vCTAEND=Peek('CTAEND','$(i)','Data');
LET vStatus=Peek('Status','$(i)','Data');
let Numsubrow=Peek('NB','$(i)','Data');
for ii=0 to '$(Numsubrow)'
load '$(vPos)' as New_Pos,'$(vCTASTART)'+'$(ii)' as CTA, '$(vStatus)' as New_Status,'$(i)' as i,'$(ii)' as ii
autogenerate 1;
Next
Next
drop table Data;
drop field i,ii;
output:
Thank you, I will try to do it
IntervalMatch() as Marcus suggested or:
Data:
Load
Pos,
CTASTART + IterNo() - 1 as CTA,
Status
inline [
Pos,CTASTART,CTAEND,Status
52,5720000,5720000,X
55,4000000,4000999,S
76,4300001,4300002,U
]
While CTASTART + IterNo() - 1 <= CTAEND;
-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com