Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Froyo
Contributor II
Contributor II

qlikview script to transform structures

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

Labels (1)
1 Solution

Accepted Solutions
Taoufiq_Zarra

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:

Capture.JPGCapture.PNG

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉

View solution in original post

4 Replies
marcus_sommer

Take a look here: IntervalMatch 

- Marcus

 

Taoufiq_Zarra

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:

Capture.JPGCapture.PNG

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Froyo
Contributor II
Contributor II
Author

Thank you, I will try to do it

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

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