Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I want to conert table from
userid | begin | end |
A | 10 | 15 |
to
userid | data |
A | 10 |
A | 11 |
A | 12 |
A | 13 |
A | 14 |
A | 15 |
Which funciion can I use? intervalmatch or another?
Thanks:)
Hello,
I would load them within a for..next similar to the exam below:
Sequence:
LOAD * Inline [
userid,begin,end
A,10,15
B,12,23
C,11,17
];
FOR vZeile=0 to fieldvaluecount( 'userid' )-1
LET vUserid= peek( 'userid' , $(vZeile) ,'Sequence');
LET vStart= peek( 'begin' , $(vZeile) ,'Sequence');
LET vEnd= peek( 'end' , $(vZeile) ,'Sequence');
// TRACE Zeile $(vZeile): $(vUserid) from $(vStart) to $(vEnd) ;
Tabl:
LOAD
'$(vUserid)' AS User,
$(vStart) + RecNo()-1 AS Value
AutoGenerate($(vEnd) - $(vStart) +1);
NEXT vZeile;
NOTES:
Had two timeconsuming issues:
First I didn't put the tablename of the peek() into single-quotes. Without quotes it works fine until using a Load()-statement within the for..next. It took me two hours of wasted time until I remembered a thread with a similar topic....
Next was that I used the rowno(). This is normally my favorite, but in this case recno() is the one.
HtH
Roland
Hello,
I would load them within a for..next similar to the exam below:
Sequence:
LOAD * Inline [
userid,begin,end
A,10,15
B,12,23
C,11,17
];
FOR vZeile=0 to fieldvaluecount( 'userid' )-1
LET vUserid= peek( 'userid' , $(vZeile) ,'Sequence');
LET vStart= peek( 'begin' , $(vZeile) ,'Sequence');
LET vEnd= peek( 'end' , $(vZeile) ,'Sequence');
// TRACE Zeile $(vZeile): $(vUserid) from $(vStart) to $(vEnd) ;
Tabl:
LOAD
'$(vUserid)' AS User,
$(vStart) + RecNo()-1 AS Value
AutoGenerate($(vEnd) - $(vStart) +1);
NEXT vZeile;
NOTES:
Had two timeconsuming issues:
First I didn't put the tablename of the peek() into single-quotes. Without quotes it works fine until using a Load()-statement within the for..next. It took me two hours of wasted time until I remembered a thread with a similar topic....
Next was that I used the rowno(). This is normally my favorite, but in this case recno() is the one.
HtH
Roland
Hi Roland,
Thank you for your reply. It's a good idea and the code works well.
I have another code, please give me some advice
Sequence:
LOAD * Inline [
userid,begin,end
A,10,15
B,12,23
C,11,17
];
n:
Load recno() as data AutoGenerate 100;
t:
intervalmatch(data) load begin,end resident Sequence;
join load * resident Sequence;
drop table Sequence;
drop table n;
drop field begin;
drop field end;
Zhou Dazhao
Hello Zhou,
yes, nice idea. There are often different ways to solve a problem efficient.
See you for next discussion!
Roland